This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index at /llms.txt, or add .md to any page's URL.
Expressions and types
ebnf
type = type-atom { "[" "]" } ; (* string[] is a list of strings *)
type-atom = "number" | "string" | "bool" | "unit" | IDENT | "action"
| "option" "<" type ">"
| "enum" "<" STRING { "," STRING } ">" ;
expr = ternary ;
ternary = binary [ "?" expr ":" expr ] ;
binary = unary { binary-op unary } ;
unary = ( "-" | "not" | "!" ) unary | postfix ;
postfix = primary { "." FIELD [ "(" [ arguments ] ")" ] } ;
primary = NUMBER | STRING | TEMPLATE | "true" | "false" | "none"
| "some" "(" expr ")" | list | IDENT
| IDENT "(" [ arguments ] ")"
| "(" expr ")" | inline-match ;
list = "[" [ expr { "," expr } [ "," ] ] "]" ;
arguments = argument { "," argument } [ "," ] ;
argument = expr | arrow | FIELD { "." FIELD } "=" expr ;
arrow = ( IDENT | "(" [ IDENT { "," IDENT } ] ")" ) "=>" expr ;
inline-match = "match" expr "{" "case" "some" "(" IDENT ")" "=>" expr
"," "case" "none" "=>" expr [ "," ] "}" ;
The binary production is precedence-resolved, not a claim that all operators
have the same precedence. From weakest to strongest:
Level | Operators | Associativity |
|---|---|---|
Conditional | ? : | Nested arms parse as expressions |
Or | or, ` | |
And | and, && | Left |
Equality | ==, != | Left |
Comparison | <, <=, >, >= | Left |
Additive | +, - | Left |
Multiplicative | *, /, % | Left |
Prefix | -, not, ! | Right |
Postfix | . | Left |
Parentheses override precedence. Comparisons do not create Python-style chained
comparison semantics. Logical operators short-circuit; ternary/match evaluates
only its selected arm. Conditions require booleans.
Named arguments are accepted only by the corresponding constructs: component
uses, a native module's sources and sends (including dotted names such as
apple.desiredAccuracy=), record construction/copy, localization (t), placeholders (empty),
canvas surface= bindings, dataTransfer=DataTransfer(…) (LLP 1094.000),
and specialized host commands such as share, scrollIntoView and the three document pickers (which take apple.message=). Ordinary function calls are positional. Arrow expressions are admitted
as the callbacks to map and filter, with at most item and index parameters;
they are not first-class values or event handlers.
In a GPU surface call, a complete positional or named argument may be
color("token.name"). The operand must be one literal string naming a
Forma colour token. This position reserves color. If the app also declares a
function named color, the surface call reports the collision. The function
can still be called elsewhere. The token constructor requires a surface argument.
An app-declared shape's call constructs a record: either all named fields, or one
positional base followed by zero or more replacements. A list literal is
a list of its items, left to right; their types meet as a ternary's arms do (type-list-item when they do
not), and a trailing comma is kept. There is no spread ([...xs, x] is
refused), object literal, bracket indexing, assignment
expression, ??, ?., or ===.
A call on a value, e.f(args), is the roster function f with e as its first
argument, for the functions the table below writes that way: the web's string
and array methods of that name and meaning (s.trim(), xs.filter(x => …),
n.toFixed(2)). e.length is the count of a list or text, or, when e is a
record whose shape declares a field named length, that field, as in
TypeScript; on a record without one it is refused. The free spelling (trim(s),
length(xs)) is refused with the edit (syntax-method-form), and so is any
other method (xs.reduce(…): syntax-method-call); the rest of the roster is
called as a function (first(xs), round(n)).
A list type is T[], as in TypeScript (Item[], option<number>[]); list<T>
is refused with the edit (syntax-list-type). A state may declare its type
(state picked: option<Item> = none), which is otherwise inferred; a derive's
type is its expression's and takes no annotation. any in an internal roster signature describes
special typing; it is not a source-language type annotation.
Is this helpful
Last updated November 30, 2026