OxL Reference

6.1 Function declaration

oxl
fn name<Generics>(params) -> ReturnType effects where Constraints { body }
fn name(params) -> ReturnType effects => expression
  • Without -> T the return type is () (for private functions with a body => e the type is inferred from e).
  • A parameter: name: T, with a default value name: T = e (evaluated on every call where the argument is omitted).
  • A variadic last parameter: ...xs: T — has type [T] inside the function.
  • Call: positional arguments, then named ones (greet("Ann", loud: true)). A positional argument after a named one is forbidden.
  • Passing: by value (move or copy). A &T parameter is borrowed automatically; for &var T the call site MUST write &var x.

arg-count, named-arg

See also

Source: docs/spec/oxl-standard.en.md