Functions

Functions are values

There’s no special syntax for declaring a function in Ascent — no function, no def, no fn name(...). A function is a value, and you bind it with fix like anything else:

fn(x: Int): Int is the signature — the parameters, then the return type after a colon. The body comes in two shapes. For a single expression, => expr says “the result is this” (that’s the => x * 2 above).

For more than one line, use a block — its last expression is the value it hands back, so there’s still no return to write:

Same function either way: => e is just shorthand for a block { e }.