You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(lang): extension functions on types — mapper Type.method(...)
Add a method to any type (primitive or user-defined) by qualifying the name:
mapper Integer.double() -> Integer => this * 2
mapper Person.fullName() -> String { return this.name + " " + this.family }
- parser: `Type.method` -> function `<TypeName>__method` with the receiver
prepended as a `this` parameter (typed via primKindToCtype/identToCtype), so
`this` / `this.field` work through ordinary codegen; emission unchanged.
- codegen: postfix dispatch `recv.method(args)` resolves to the extension when
`<recvXtype>__method` exists, passing the receiver as the first arg. Keyed on
the xtype (the type name, e.g. "Integer"/"Person"), so it matches receivers and
chains (`n.double().plus(1)`). Any function kind works.
Verified on primitives, String, user types, predicates, args, chaining;
self-hosting fixpoint byte-identical; adds examples/extensions_test.xi.
0 commit comments