Keywords
Reserved
Section titled “Reserved”These words can never be a name. They can’t be used for a variable, a function, a parameter, a class, a field, a method, an import alias, a loop label or a sample in a pattern.
| Keyword | What it is |
|---|---|
let | Declares a variable. See Variables & Scope |
fn | Defines a function. See Functions |
return | Leaves a function with a value. See Functions |
class | Defines a class. See Classes |
use | Imports a module. See Modules |
as | Renames an import. See Modules |
private | Keeps a definition out of a module’s exports. See Modules |
dsp | Starts a dsp definition. See DSP Blocks |
if | Runs code when a condition holds. See Control Flow |
else | The other branch of an if. See Control Flow |
match | Picks a branch by value. See Control Flow |
loop | Repeats until break. See Control Flow |
do | Repeats a set number of times. See Control Flow |
for | Iterates. See Control Flow |
in | Names what for iterates. See Control Flow |
break | Leaves a loop. See Control Flow |
continue | Starts a loop’s next iteration. See Control Flow |
assert | Stops with an error when a condition fails. See Control Flow |
true | The Boolean true. See Values & Types |
false | The Boolean false. See Values & Types |
NUL | The absence of a value. See Values & Types |
PLAY | Starts the play head. See Transport |
PAUSE | Holds the play head where it is. See Transport |
STOP | Returns the play head to the start. See Transport |
RESET | Discards the whole session. See Transport |
RECORD | Plays, and records the armed tracks. See Transport |
SEEK | Moves the play head to a cycle. See Transport |
Using a keyword as a name is a parse error, reported at the word:
let if = 7;// → Parse error at 1:5: `if` is a keyword and cannot be used as a nameA keyword only counts when it stands as a whole word, so letter, iffy and PLAYING are all
ordinary names.
DSP words
Section titled “DSP words”The words a dsp definition is made of, such as effect,
param, state, input, output, range and process, are only keywords where that
definition expects them. Everywhere else they are ordinary names. That includes the code inside a dsp definition, and functions such as
track.set_input(...) and range(...).
let state = 1;let input = range(0, 3);assert state == 1;