the things you work with
Values & lists
Numbers, text, lists, and bytes — Vision's core value types, with real examples.
Numbers
Vision has whole numbers and decimals. Underscores in number literals are allowed for readability and ignored by the compiler.
a count is 42 a ratio is 0.618 a big is 1_000_000 // underscores for readability
Text
Text values are written in double quotes. Text interpolation embeds an
expression with curly braces: "{the name}" splices the
value of the name into the string at that position.
a name is "Marigold" a path is "/home/june/notes.txt" a greeting is "hello, {name}" // text interpolation
Text is immutable. To build text up piece by piece, collect pieces in a list
and join them. Joining with followed by works for two pieces at
a time.
Lists
A list from known values uses are. An empty growable list uses
a list of. Positions are 1-based — position 1
is the first value.
favorite numbers are 4, 8, 15, 16, 23, 42 the samples are a list of decimals add 0.5 to the samples the third is the value at 3 in favorite numbers the head is the first value in favorite numbers the count is how many are in favorite numbers for each number in favorite numbers say number
add appends to the end. There is no index-based write — to
change a value at a position, build a new list.
Bytes
A byte is a whole number from 0 to 255. A list of bytes holds raw binary data and is used when talking to C libraries or reading/writing files.
the data is a list of bytes add 255 to the data add 0 to the data
Described things
A described thing is a named bundle of fields (a struct). Declare
it with a Name has:, then list the fields. Read a field with
the field of the thing; write it with set the field of the thing to.
a Point has: an x a y the origin is a Point set the x of the origin to 0 set the y of the origin to 0
Named sets
A named set is an enumeration (an enum). Declare it with
a Name is one of. Check membership with is one of.
a Direction is one of north, south, east, west if the heading is one of north, south say "going vertical"