Skip to content

List<T> and Map<K,V> as real classes #37

Description

@NightmarePog

`List` and `Map` are currently special — the `[]` and `[key: val]` literals emit special `__lz_list` / `__lz_map` constructors, and HOFs like `map`, `filter`, and `fold` are static functions that take the collection as their first argument.

Converting them to proper classes would fix several things at once:

  • Method dispatch via the class table (`xs.map(f).filter(g)` instead of nesting)
  • Generics work correctly at the type level
  • The type system can reason about `List` and `Map<K,V>` without special-casing them

Additional methods worth adding when this lands: `reverse()`, `sort()`, `sort_by(f)` on List; `entries()`, `merge(other)` on Map.

This is a significant change that touches the lexer (literal syntax), typechecker (special-cased types), and codegen (list/map construction and dispatch).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions