Skip to content

function

pannous edited this page Oct 3, 2026 · 7 revisions

Functions can be defined in the following natural ways:

function square (n: number){ n*n }
to square a number: return it * it
square of a number = it * it
square(number n)=n*n
square(n)=n*n
square:=it*it

The parser should differentiate between variables and functions via these heuristics:

  1. functions have braces left of the assignment square(n)=n*n or
  2. functions have blocks right of the assignment square = {it*it} or
  3. functions use := for the assignment square:=it*it

The difference to square=it*it is that variables get evaluated instantly and only once, whereas The function square:=it*it is a dangling closure

Under the hood all are represented equally: as the charged data

square = {it*it}

Together with an entry in the pattern dictionary [:square, number] => &square denoting that the symbol 'square' together with the type number should be resolved to the function square.

Functions are unary prefix operators, that is in an expression a f b c they get parsed as a (f (b c))

Every function generates a suffix operator: square 2 == 2 squared

The suffix word is the function name plus d or ed (squared, sorted) for any function taking an argument. An ungrouped mix with arithmetic, 1+2 squared, is ambiguous: the compiler asks whether it means 1+(2 squared) or (1+2) squared (user, 2026-10-03); unanswered it is an error naming both forms. 2 squared+1 is (2 squared)+1.

Home

Philosophy •

data & code blocks

features

inventions

evaluation

keywords

iteration

tasks

examples

todo : bad ideas and open questions

⚠️ specification and progress are out of sync

Clone this wiki locally