Built-in types
ANY · ARRAY · BOOLEAN · COORDINATE · ERROR · FLOAT · FUNCTION · FUTURE · INTEGER · MAP · RANGE · STRING · VECTOR
ANY
Any value at all. Use it where a parameter or field isn’t limited to one type.
ARRAY
An ordered list of values, counted from 0. Write a size, a colon and a type and I make one that long, every item as that type starts: 10:INTEGER is ten zeros, and a coordinate for the size, as in (4, 3):INTEGER, gives rows of rows. Arrays are shared: two variables holding the same array see each other’s changes. A field of this type starts as an empty array.
Make one longer or shorter with + and -, which give you a new array: list + "item" adds an item, list + [1, 2] joins another array on, list + 2 adds two empty items, and list - 1 takes the last one off. An empty item is the same kind as the one the array ends with — 0 after numbers, "" after strings, a fresh object after objects — or NULL if the array is empty.
To change an array where it is, without a copy, use PUSH and POP at the end and QUEUE and DEQUEUE for a line: in at the back, out at the front. Each is one quick step however long the array is.
Examples
scores = [10, 20]
scores(1) = 25
row = 10:INTEGER
grid = (4, 3):INTEGER
grid(1, 2) = 7
scores = scores + [30]
scores = scores - 1
names = ["ada"] + "grace"
PUSH stack, 5
top = POP(stack)
QUEUE orders, "soup"
next = DEQUEUE(orders)
BOOLEAN
TRUE or FALSE: a yes or a no. Underneath they’re the numbers 1 and 0, so they add up and compare like any number, and IF takes anything. Naming this type says a value is meant as an answer, and that’s how I describe it wherever it’s documented. A field of this type starts as FALSE.
Example
ready = TRUE
IF ready THEN PRINT "go"
COORDINATE
Two or more numbers in parentheses. If every number is whole, the coordinate is whole; otherwise I make them all floats. A dimension a coordinate doesn’t have counts as 0.
A coordinate is a plain value, like a number: assigning it makes a copy. You can read and write its parts with .x, .y, .z, .w, or by position. A field of this type starts at (0, 0).
Example
pos = (10, 20)
pos.x = pos.x + 1
PRINT pos + (5, 0), pos * 2
ERROR
A value that says something went wrong, made with ERROR(code, values). An error is false, so you can test it with IF or ISERROR. Use it any other way — in arithmetic, say, or as an argument to most host functions — and I stop the script and report it.
Example
score = score_of("linus")
IF ISERROR(score) THEN PRINT "no such player"
FLOAT
A number with a fraction. Write it with digits on both sides of the point, or with an exponent. A field of this type starts at 0.0.
Example
speed = 2.5
far = 1e6
FUNCTION
A function held as a value. A function’s name without parentheses is the function itself, which you can store, pass along and call later. A method without parentheses remembers its object.
Example
action = double
PRINT action(4)
FUTURE
The answer from an ASYNC call, which may not have arrived yet. Give it to RESOLVE and I’ll wait for the answer. Until then I can’t use it as an ordinary value.
Example
answer = ASYNC slow_sum(1, 2)
PRINT RESOLVE(answer)
INTEGER
A whole number, 64 bits wide — that’s all the room I have for one. Arithmetic that goes past the largest or smallest value wraps around. Write it in decimal, in hex as 0xFF, or in binary as 0b1010. A field of this type starts at 0.
Example
lives = 3
mask = 0xFF
MAP
Values stored under string keys, which I keep in sorted order. Maps are shared, like arrays. A whole number used as a key is stored as its digits. A field of this type starts as an empty map.
Example
ages = {ada: 36}
ages("grace") = 85
RANGE
Two whole numbers and every whole number between them, made with ... or TO. A range is a real value: you can store it, pass it around and compare it. A field of this type starts at 0 ... 0.
Example
FOR i = 1 ... 3
PRINT i
END FOR
STRING
Text, written in double quotes. \" and \\ put a quote or a backslash inside, and \n a new line. A field of this type starts at "".
Example
name = "ada"
PRINT "hello, " + name
VECTOR
Two coordinates, a start and a stop, made with ->. A plain value, like a coordinate. A field of this type starts at (0, 0) -> (0, 0).
Example
path = (0, 0) -> (10, 5)
PRINT path.start, path.stop