Program
line 1Results
Run a program to see what it prints.
The stack is empty.
| # | Instruction | Line |
|---|
Nothing compiled yet.
Writing Raft
Raft is postfix and stack-based: operands first, then the instruction that
consumes them. 5 3 - pushes 5 and 3 and leaves 2.
# and // start a comment.
A name beginning with a dot is a label — .loop marks a spot,
and Jump .loop goes there.
Instruction set
- Literals
42-3.14truefalse"a string"- Arithmetic
-
+-*/%^— or by name:AddSubMulDivModExpNeg - Comparison
-
EqNeLtLeGtGe— each leaves a boolean. Ordering needs two integers or two floats; equality is defined for any pair. - Logic
NotAndOr— operands are booleans, and neither side short-circuits.- Stack
PopDupSwap- Variables
StoreVar 0LoadVar 0— slots are numbered, not named.- Control flow
-
Jump .labelJumpIfFalse .labelCall .labelReturn - Strings and arrays
-
PushString "hi"MakeString hiStringConcatMakeArray 3ArrayGetArraySet - Modules
-
MakeModule 1 nameModuleGet nameModuleSet nameLoadGlobal ioGetExport print - Native calls
-
io.print CallNative 1—io.printloads the standardiomodule's export, andCallNativecalls it with that many arguments from the stack. - Actors
-
SpawnActor .bodySendMessageReceiveMessage— spawning leaves the actor on the stack; sending takes a message below it and leaves the actor there to send again. - Supervision
-
SpawnSupervisor .bodySetStrategy 0|1|2SuperviseChild <address>RestartChild <address>— strategies are one-for-one, one-for-all and rest-for-one.
How this page runs your program
This is the VM from the repository compiled to WebAssembly, not a reimplementation: the same compiler, the same opcodes, the same heap and garbage collector. It runs in a worker under an instruction budget, and the page stops a run that outlasts its stopwatch, so a program that loops forever costs you a message rather than the tab.
Ready.