TYCHO Search

Search documentation

    ↑ ↓ to move · Enter to open · Esc to close

    Function design notes (maintainers)

    Why the user-facing behavior in reference/functions.md is sound. Users don't need this page.

    Capture by value

    A closure captures its environment by value (deep copy) when created, so the closure is independent of later changes to the originals. On return the captured environment moves into the caller's scope — the same cross-scope move as any other escaping value, via the closure's generated environment-copy routine. No lifetime annotations are needed, and a stored closure (in an array, struct field, or map value) carries its environment the same way. The higher-order patterns this covers (map/filter/reduce, predicates, comparators, factories, dispatch tables) have examples in corelib/iter.

    Parameter modes

    Methods

    UFCS (x.foo(a) for foo(x, a)) resolves on the receiver's compile-time type with no dynamic dispatch. A built-in in receiver position rewrites to the plain call under identical argument rules. A same-named fn-typed field wins over a free function.