Data types
Vocabulary: push means "place on the top of the stack" and pull means "remove from the top of the stack".
All values have a type characterising their properties.
Arguably the most important type in the language. A list is an ordered sequence of zero or more values (that can be other lists). Values contained in a list do not need to be of the same type (i.e. lists can be heterogenous).
A list begin with [
and end with ]
. All values located between these delimiters are the contents of the list. Values do not need to be separated by commas as it is the case in many languages.
[]
[42 hello]
[1 2 3]
[ [3.14] foo ]
The list is pushed without being itself executed.
A symbol is a named value. It is mainly used as an identifier to reference a value defined in a different part of a program.
A symbol can begin with any letter (A
to Z
, a
to z
) or one of the following characters: ~!@#$%^&*_+-=|\;,.<>?/
, followed by zero or more characters of the same set extended with digits (0
to 9
). The sequence --
forms the beginning of a comment, thus a symbol cannot use it.
foo
+
Hello-World
Look for a reserved value or a defined operation. Push a copy of the value or execute the operation, respectively. If nothing is found, raise an error.
A quoted symbol is similar to a symbol but with different semantics.
A quoted symbol begins with :
followed by a symbol.
:foo
:+
:Hello-World
Push the quoted symbol.
A boolean is either true or false. There isn't any special syntax for booleans: They are created with the operations TRUE
and FALSE
.
Push the boolean.
A number represents… well, a number. There is no distinction between integers and floats: They are just numbers.
42
3.14
-1
Push the number.
A character is signaled by '
followed by the character to represent. Whitespace characters space, tabulation and new-line are represented with \s
, \t
and \n
, respectively. The \
character is represented with \\
.
'a
'1
\n
Push the number.
A string is not actually a type: It's just a list containing only characters. As a shortcut, a string can be represented with the delimiters "
. The "
character inside a string is represented with """.
-
"abc"
(equivalent to['a 'b 'c]
) "hello world"
"\"Nono\""