Syntax

In most lists, the first item is an operator. Stardust calculates the arguments first. Then it applies the operator to them. The names on this page control which arguments Stardust calculates or give a value.

An expression produces a value. A literal expression, such as 5, adult or true, produces itself. A variable expression starts with ? and reads a named value.

TRON371 B
Offset (hex)Bytes (hex)Meaning
00054 52 4F 4Emagic TRON
0043C 616765txt "age"
00802 24000000000000 00i64 36
0110F 0A 04000000 0800 0000map leaf, size 10: @4 → @8
01B4C 726F6C65txt "role"
0208C 656E67696E6565 72txt "engineer"
0290F 0A 1B000000 2000 0000map leaf, size 10: @1B → @20
0334C 6E616D65txt "name"
0383C 416461txt "Ada"
03C0F 0A 33000000 3800 0000map leaf, size 10: @33 → @38
04607 12 00910000 1100 0000 29000000 3C00 0000map branch, size 18, depth 0 (root), slots 8, 12, 15: @11 → @29 → @3C
0585C 236C696E6Btxt "#link"
05E5C 235F616461txt "#_ada"
0640F 0A 58000000 5E00 0000map leaf, size 10: @58 → @5E
06E3C 616765txt "age"
07202 29000000000000 00i64 41
07B0F 0A 6E000000 7200 0000map leaf, size 10: @6E → @72
0856C 6D656E746F72txt "mentor"
08C0F 0A 85000000 6400 0000map leaf, size 10: @85 → @64
0964C 726F6C65txt "role"
09B8C 656E67696E6565 72txt "engineer"
0A40F 0A 96000000 9B00 0000map leaf, size 10: @96 → @9B
0AE4C 6E616D65txt "name"
0B33C 426F62txt "Bob"
0B70F 0A AE000000 B300 0000map leaf, size 10: @AE → @B3
0C107 16 00990000 7B00 0000 8C000000 A400 0000 B7000000map branch, size 22, depth 0 (root), slots 8, 11, 12, 15: @7B → @8C → @A4 → @B7
0D73C 616765txt "age"
0DB02 1D000000000000 00i64 29
0E40F 0A D7000000 DB00 0000map leaf, size 10: @D7 → @DB
0EE4C 726F6C65txt "role"
0F38C 64657369676E65 72txt "designer"
0FC0F 0A EE000000 F300 0000map leaf, size 10: @EE → @F3
1064C 6E616D65txt "name"
10B2C 4379txt "Cy"
10E0F 0A 06010000 0B01 0000map leaf, size 10: @106 → @10B
11807 12 00910000 E400 0000 FC000000 0E01 0000map branch, size 18, depth 0 (root), slots 8, 12, 15: @E4 → @FC → @10E
12A4C 235F6379txt "#_cy"
12F0F 0A 2A010000 1801 0000map leaf, size 10: @12A → @118
1395C 235F626F62txt "#_bob"
13F0F 0A 39010000 C100 0000map leaf, size 10: @139 → @C1
1495C 235F616461txt "#_ada"
14F0F 0A 49010000 4600 0000map leaf, size 10: @149 → @46
15907 12 80210000 2F01 0000 3F010000 4F01 0000map branch, size 18, depth 0 (root), slots 7, 8, 13: @12F → @13F → @14F

Branches

if has a condition, a result for true, and an optional result for false. Only null and false are false. Stardust calculates only the branch that it uses. Without the last argument, a false condition gives null.

TRON89 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
041C 3Etxt ">"
064C 3F616765txt "?age"
0B02 12000000000000 00i64 18
140E 15 00 0700 030000 00 04000000 060000 00 0B000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @6 → @B
292C 6966txt "if"
2C5C 6164756C74txt "adult"
325C 6D696E6F72txt "minor"
380E 19 00 0F00 040000 00 29000000 140000 00 2C000000 320000 00array leaf, size 25, shift 0, bitmap 000F, count 4 (root): @29 → @14 → @2C → @32
TRON18 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 6164756C74txt "adult"

when and unless each have a condition and one result. when gives the result when the condition is true.

TRON81 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
041C 3Etxt ">"
064C 3F616765txt "?age"
0B02 12000000000000 00i64 18
140E 15 00 0700 030000 00 04000000 060000 00 0B000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @6 → @B
294C 7768656Etxt "when"
2E5C 6164756C74txt "adult"
340E 15 00 0700 030000 00 29000000 140000 00 2E000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @29 → @14 → @2E
TRON18 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 6164756C74txt "adult"

unless gives the result when the condition is false.

TRON54 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
046C 756E6C657373txt "unless"
0B8C 3F626C6F636B65 64txt "?blocked"
144C 73656E64txt "send"
190E 15 00 0700 030000 00 04000000 0B0000 00 14000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @B → @14
TRON17 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
044C 73656E64txt "send"

In the other case, each one gives null. Neither operator accepts a second result.

cond has pairs of condition and result. It gives the result of the first true condition.

TRON148 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
041C 3Ctxt "<"
062C 3F6Etxt "?n"
0902 00000000000000 00i64 0
120E 15 00 0700 030000 00 04000000 060000 00 09000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @6 → @9
271C 3Dtxt "="
292C 3F6Etxt "?n"
2C02 00000000000000 00i64 0
350E 15 00 0700 030000 00 27000000 290000 00 2C000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @27 → @29 → @2C
4A4C 636F6E64txt "cond"
4F8C 6E656761746976 65txt "negative"
584C 7A65726Ftxt "zero"
5D09bit true
5E8C 706F7369746976 65txt "positive"
670E 25 00 7F00 070000 00 4A000000 120000 00 4F000000 350000 00 58000000 5D0000 00 5E000000array leaf, size 37, shift 0, bitmap 007F, count 7 (root): @4A → @12 → @4F → @35 → @58 → @5D → @5E
TRON21 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
048C 706F7369746976 65txt "positive"

and and or stop at the first argument that sets the answer. Both give true or false.

Variables that you set

let sets variables for the rest of the expression. Variable names and values come in pairs. Each binding and reference uses ?name, and each value can read the variables above it.

TRON141 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
041C 2Btxt "+"
062C 3F61txt "?a"
0902 01000000000000 00i64 1
120E 15 00 0700 030000 00 04000000 060000 00 09000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @6 → @9
272C 3F61txt "?a"
2A02 05000000000000 00i64 5
332C 3F62txt "?b"
360E 19 00 0F00 040000 00 27000000 2A0000 00 33000000 120000 00array leaf, size 25, shift 0, bitmap 000F, count 4 (root): @27 → @2A → @33 → @12
4F1C 2Atxt "*"
512C 3F61txt "?a"
542C 3F62txt "?b"
570E 15 00 0700 030000 00 4F000000 510000 00 54000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4F → @51 → @54
6C3C 6C6574txt "let"
700E 15 00 0700 030000 00 6C000000 360000 00 57000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @6C → @36 → @57
TRON21 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
0402 1E000000000000 00i64 30

The same spelling declares and reads a variable. If let or fn does not declare the variable, the caller must give its value. A local declaration with the name of a caller variable replaces that variable for the rest of the expression.

TRON101 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
042C 3F78txt "?x"
0702 02000000000000 00i64 2
100E 11 00 0300 020000 00 04000000 070000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @7
211C 2Btxt "+"
232C 3F78txt "?x"
2602 01000000000000 00i64 1
2F0E 15 00 0700 030000 00 21000000 230000 00 26000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @21 → @23 → @26
443C 6C6574txt "let"
480E 15 00 0700 030000 00 44000000 100000 00 2F000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @44 → @10 → @2F
TRON21 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
0402 03000000000000 00i64 3

A plain word in value position stays text.

TRON106 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 3F6E616D65txt "?name"
0A02 07000000000000 00i64 7
130E 11 00 0300 020000 00 04000000 0A0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A
244C 6C697374txt "list"
294C 6E616D65txt "name"
2E5C 3F6E616D65txt "?name"
340E 15 00 0700 030000 00 24000000 290000 00 2E000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @24 → @29 → @2E
493C 6C6574txt "let"
4D0E 15 00 0700 030000 00 49000000 130000 00 34000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @49 → @13 → @34
TRON43 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
044C 6E616D65txt "name"
0902 07000000000000 00i64 7
120E 11 00 0300 020000 00 04000000 090000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @9

Functions

fn makes a function. It has a list of parameter names and a body. Some operators use a function directly.

TRON164 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
046C 3F76616C7565txt "?value"
0B0E 0D 00 0100 010000 00 04000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
181C 2Atxt "*"
1A6C 3F76616C7565txt "?value"
2102 02000000000000 00i64 2
2A0E 15 00 0700 030000 00 18000000 1A0000 00 21000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @18 → @1A → @21
3F2C 666Etxt "fn"
420E 15 00 0700 030000 00 3F000000 0B0000 00 2A000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3F → @B → @2A
574C 6C697374txt "list"
5C02 01000000000000 00i64 1
6502 02000000000000 00i64 2
6E0E 15 00 0700 030000 00 57000000 5C0000 00 65000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @57 → @5C → @65
833C 6D6170txt "map"
870E 15 00 0700 030000 00 83000000 420000 00 6E000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @83 → @42 → @6E
TRON47 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
0402 02000000000000 00i64 2
0D02 04000000000000 00i64 4
160E 11 00 0300 020000 00 04000000 0D0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @D

Each parameter uses ?name to declare a variable. The parameter names must be different from each other. A reference in the function body starts with ?. A function has a maximum of eight parameters. The body can also use each variable from a let around it.

You can also give a function a name with let. Put its variable reference first in a list. Stardust then calculates the function with the other items as its arguments.

TRON179 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
046C 3F76616C7565txt "?value"
0B0E 0D 00 0100 010000 00 04000000array leaf, size 13, shift 0, bitmap 0001, count 1 (root): @4
181C 2Atxt "*"
1A6C 3F76616C7565txt "?value"
2102 02000000000000 00i64 2
2A0E 15 00 0700 030000 00 18000000 1A0000 00 21000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @18 → @1A → @21
3F2C 666Etxt "fn"
420E 15 00 0700 030000 00 3F000000 0B0000 00 2A000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @3F → @B → @2A
577C 3F646F75626C65txt "?double"
5F0E 11 00 0300 020000 00 57000000 420000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @57 → @42
707C 3F646F75626C65txt "?double"
7802 03000000000000 00i64 3
810E 11 00 0300 020000 00 70000000 780000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @70 → @78
923C 6C6574txt "let"
960E 15 00 0700 030000 00 92000000 5F0000 00 81000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @92 → @5F → @81
TRON21 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
0402 06000000000000 00i64 6

Literal values

list makes a list. Stardust calculates each item, then keeps the results in order. The empty list is [].

TRON101 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
041C 2Btxt "+"
0602 01000000000000 00i64 1
0F02 02000000000000 00i64 2
180E 15 00 0700 030000 00 04000000 060000 00 0F000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @6 → @F
2D4C 6C697374txt "list"
3202 01000000000000 00i64 1
3B02 02000000000000 00i64 2
440E 19 00 0F00 040000 00 2D000000 320000 00 3B000000 180000 00array leaf, size 25, shift 0, bitmap 000F, count 4 (root): @2D → @32 → @3B → @18
TRON60 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
0402 01000000000000 00i64 1
0D02 02000000000000 00i64 2
1602 03000000000000 00i64 3
1F0E 15 00 0700 030000 00 04000000 0D0000 00 16000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @D → @16

A map is an ordinary document. Stardust calculates each value in it and keeps each name.

TRON100 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
041C 2Btxt "+"
0602 01000000000000 00i64 1
0F02 01000000000000 00i64 1
180E 15 00 0700 030000 00 04000000 060000 00 0F000000array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @6 → @F
2D1C 61txt "a"
2F02 01000000000000 00i64 1
380F 0A 2D000000 2F00 0000map leaf, size 10: @2D → @2F
421C 62txt "b"
440F 0A 42000000 1800 0000map leaf, size 10: @42 → @18
4E07 0E 40800000 3800 0000 44000000map branch, size 14, depth 0 (root), slots 6, 15: @38 → @44
TRON68 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
041C 61txt "a"
0602 01000000000000 00i64 1
0F0F 0A 04000000 0600 0000map leaf, size 10: @4 → @6
191C 62txt "b"
1B02 02000000000000 00i64 2
240F 0A 19000000 1B00 0000map leaf, size 10: @19 → @1B
2E07 0E 40800000 0F00 0000 24000000map branch, size 14, depth 0 (root), slots 6, 15: @F → @24

Text, numbers, true, false and null are values. Stardust gives each one without a change. A list whose first item is not text is also a list of values. list makes this clear to the reader.

Some other languages use quote to stop the evaluation of a list. Stardust reserves the name and rejects it. A plain word is already text, so a program needs no operator for this.

TRON37 B
Offset (hex)Bytes (hex)Meaning
0054 52 4F 4Emagic TRON
045C 71756F7465txt "quote"
0A1C 61txt "a"
0C0E 11 00 0300 020000 00 04000000 0A0000 00array leaf, size 17, shift 0, bitmap 0003, count 2 (root): @4 → @A

Error

Unsupported_Node: quote is not supported yet

Run it

build · program evaluate.