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.
Task
Implement method-call sugar so that
xs.len()desugars tolen(xs), etc. Applies to all three collection types:List[T],Map[K, V], andSet[T].Desugaring table
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
expr.method(args)on collection typesList[T],Map[K, V], andSet[T]Spec
See PDP-009: Collection Types.