Functions
Named function (block body)
Section titled “Named function (block body)”fn greet name console.log[name]Compiles to:
function greet(name) { console.log(name);}Named function (expression body)
Section titled “Named function (expression body)”fn double x to x mul 2function double(x) { return x * 2;}Multiple parameters
Section titled “Multiple parameters”Use ; to separate parameters:
fn add a; b return a add bfunction add(a, b) { return a + b;}Anonymous functions
Section titled “Anonymous functions”const double be fn x to x mul 2const double = (x) => x * 2;Async functions
Section titled “Async functions”async fn fetch-data url const res be await fetch[url] return resasync function fetchData(url) { const res = await fetch(url); return res;}Function calls
Section titled “Function calls”Use [] instead of ():
greet[///world///]add[1; 2]console.log[///hello///]greet("world");add(1, 2);console.log("hello");Type annotations (erased)
Section titled “Type annotations (erased)”fn add a of Number; b of Number gives Number to a add bType annotations with of and gives are erased in the JavaScript output.
Return
Section titled “Return”fn get-value return 42