Values are a set of key-value pairs. Keys are just normal Paws values. Values may also have some invisible data attached to them, accessible only through system-provided routines, e.g. numbers accessible through system-provided routines for arithmetic.
Each value has an associated routine to handle “juxaposition”. Juxaposition is when you put two values next to each other like this: a b
. The routine associated with the value on the left is executed with both values as arguments. The default is to look up the value on the right against the key-value pairs of the object on the right.
A prominent example of different functionality can be seen in routines themselves. A routine is a normal Paws value with some invisible data attached to it, representing Paws code to be executed (as well as another Paws object representing the routine's local scope), and the routine's associated juxtaposition handler simply executes that routine with the value on the right as its argument.
A program is a sequence of ;
- or newline-separated expressions.
An expression is:
- a number
- a string
- a symbol
- an expression surrounded by
(
and)
- a program surrounded by
{
and}
- a sequence of expressions
A program represents a routine that is immediately executed. When a routine is executed, each of its expressions is executed in an undetermined order, potentially simultaneously.
The Paws interpreter sees an invisible value representing the locals-object of the current routine at the beginning of every line in a routine and at the beginning of parentheses-delimited expressions. In other words, when you write a (b c)
, the Paws interpreter sees <locals> a (<locals> b c)
.
To execute a sequence of expressions, the Paws interpreter executes the first two sub-expressions, then juxtaposes their results, continuing until there are no more juxtapositions to perform. For example, in a b c
, first, the symbol “a” is juxtaposed against the current routine's locals-object, and then the symbol “b” is juxtaposed against the result of that, and then the symbol “c” is juxtaposed against the result of that. After this, are no more juxtapositions to perform, so execution is finished.
However, each step of this process might happen multiple times or not at all. When a line of a routine spins off another routine, execution of the line is suspended, and a continuation representing its further execution is given to the routine. If every routine called the continuation given to it once, with a return value, the result would be semantically identical to a normal call stack. However, a routine could choose not to return at all, or to return multiple times. For example, imagine an each
method of a list that calls back the continuation once for each element in the list.