menu
169 tokens

Functions

Functions, lambdas and captures.

Functions

src/functions.ds.ds
1function add(left: int32, right: int32): int32 {2    left + right3}4 5const double = (value: int32) => value * 2;
  • FunctionPointer for raw / think function pointers without environment

  • declarations do not nest in function bodies, except function, type, and newtype — a nested class, struct, enum, interface, or extension is a compiler error

  • nested type and newtype declarations may reference enclosing generics; both erase, so no instantiation identity is created

Overloading

  • dispatch and coherence
  • need some .. coherent model
  • first-match wins
  • function overloading only within same declaration scope (single struct, class, extension, ..)