-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
Support method-call syntax as sugar over existing collection builtins.
Proposal
xs.len()desugars tolen(xs)xs.contains(v)desugars tocontains(xs, v)xs.get(i)desugars toget(xs, i)xs.add(v)desugars toadd(xs, v)xs.remove(i)desugars toremove(xs, i)
Rules
- Sugar only: behavior and types must match the builtin forms exactly
- Mutability checks are unchanged (e.g.
add/removerequire mutable receiver) - No user-defined extension methods in this issue
Scope (Minimal)
- Parser: keep existing
obj.method(args)shape - Type checker: resolve supported collection methods to builtin signatures
- Interpreter: dispatch method calls to builtin implementations
Acceptance Criteria
const n = [1,2,3].len();behaves likelen([1,2,3]);var xs = [1,2]; xs.add(3);behaves likeadd(xs, 3);const xs = [1,2]; xs.add(3);fails with mutability error- Unknown methods (e.g.
xs.foo()) fail with type error
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels