Skip to content

Add method-call sugar for collection builtins (xs.len() style) #34

@synapticvoid

Description

@synapticvoid

Task

Implement method-call sugar so that xs.len() desugars to len(xs), etc. Applies to all three collection types: List[T], Map[K, V], and Set[T].

Desugaring table

Method form Desugars to
xs.len() len(xs)
xs.contains(v) contains(xs, v)
xs.get(i) get(xs, i)
xs.get(i, d) get(xs, i, d)
xs.add(v) add(xs, v)
xs.remove(i) remove(xs, i)

Sugar only — behavior and types match the builtin forms exactly.

Acceptance criteria

  • Parser recognizes expr.method(args) on collection types
  • AST desugars to builtin call before type-checking
  • Works for List[T], Map[K, V], and Set[T]

Spec

See PDP-009: Collection Types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions