mem: typed allocation helpers + drop bare malloc/free (Phase 2.2); resolve 0119 as |>-contract clarification
This commit is contained in:
14
specs.md
14
specs.md
@@ -2291,7 +2291,19 @@ p := Point.{3, 4};
|
||||
print("{}\n", p.point_sum()); // calls point_sum(p) → 7
|
||||
```
|
||||
|
||||
UFCS works with pointer receivers (auto-deref applies) and generic functions. If the field name exists as both a struct field and a free function, the struct field takes priority.
|
||||
UFCS works with pointer receivers (auto-deref applies). Generic struct
|
||||
*methods* dispatch via dot; a generic **free function** (any `$T` in its
|
||||
signature) is NOT dot-rewritten — call it directly or fluently via the
|
||||
pipe operator, which desugars at parse time to the direct call:
|
||||
|
||||
```sx
|
||||
first_of :: (xs: []$T) -> T { xs[0] }
|
||||
|
||||
first_of(xs); // direct
|
||||
xs |> first_of(); // fluent — desugars to first_of(xs)
|
||||
```
|
||||
|
||||
If the field name exists as both a struct field and a free function, the struct field takes priority.
|
||||
|
||||
#### UFCS Aliases
|
||||
The `ufcs` keyword creates a name alias for a function, decoupling the method name from the function name:
|
||||
|
||||
Reference in New Issue
Block a user