In order to maximize readability, tolerance, and portability (the top goals of the language), MSL can exist in two forms: a short form (called the 1-form) which depends on its containing expression to resolve values and a full form (called the 2-form) which does not. Using this methodology, an entire Mimix machine can be resolved into a single expression which is entirely portable. Likewise, any part down to an atom can also be fully resolved and exported or imported as a self-contained unit.
The 1-form of the language is useful for recording editing sessions, for writing MSL scripts for others, and for entering into a REPL-type command line environment. The 1-form includes many shortcuts, optional features, and defaults in order to minimize the amount of MSL that needs to be written and to make the source more readable. However, every 1-form expression must be able to be recast immediately into 2-form in order to be accepted by the engine.
The simplest 1-form expression recalls the value of an atom, which must be previously defined (in a 2-form expression). The 1-form atom expression is written (@ key).
(@ charlie-brown) ⇒ Charlie Brown
A shortcut is to write the key up against the @ sign and, in fact, this is the more typical syntax.
(@charlie-brown) ⇒ Charlie Brown
In the 1-form
, an expression has only a key-sequence which must be unique within its namespace (stream, view, canon, atom, or metadata). The key-sequence is the one and only parameter to the expression, hence 1-form
. When new expressions are generated (by copying, for example) the viewer assigns a new key immediately. The viewer can use any strategy to assign keys, such a sequential numbers, UUIDs, or lookup of existing atom values for possible matches. The same strategy must be applied anytime an invalid key is referenced in typed or imported code (for example, a key with spaces or another invalid name). Any expression which contains a 1-form
expression is, itself, a 1-form
expression.
In the 1-form
, an expression relies on a previous 2-form
expression with the same key to derive its value. 1-form
expressions are not portable outside the element in which they're contained. The viewer may insert the 1-form
inside a containing expression where it is valid, but nowhere else. The system always checks its internal representation of the atom's values to make sure that a 2-form
can be derived.
In the 2-form
, every expression is a setter. Setter expressions have 2 (or more) parameters which essentially reduce to 2 parameters: a key-sequence and a value, thus 2-form
. There are no getters and no reliance on previous values. The 2-form
of MSL can be directly displayed in a viewer or exported to any other context.
(@CharlieBrown Charlie Brown)
(@CharlieBrown Charlie Brown :creator (@CharlesShultz Charles Shultz))
In both the examples, the atoms fully set their values so both are examples of 2-form
.
Any 1-form
expression can be recast to 2-form
by retrieving the current value of the atom and adding it as a value parameter.
(@CharlieBrown Charlie Brown :creator (@CharlesShultz Charles Shultz))
(@CharlieBrown) ⇒ (@CharlieBrown Charlie Brown)
(@CharlieBrown :creator) ⇒ (@CharlieBrown Charlie Brown :creator (@CharlesShultz Charles Shultz))
If these three atoms appeared in this order in a view, the first one provides a value for the atom itself, "Charlie Brown" and some metadata. The second expression (in 1-form
) can be converted to 2-form
by adding the value of the atom from the previous expression with the same key. The third expression references metadata (in 1-form
) and can be converted to 2-form
by resolving the atom's value and metadata references.
When constructing the 2-form
, the viewer takes only the data needed to resolve the atom's value.
Any getter can be rewritten in 2-form
as a setter simply by running all the getters within it and adding the values they return as a second parameter in the expression. This turns the getters into setters and makes the single 2-form
expression fully portable.
//set the keys to their original values
(@GEORGE George Washington)
(@USA United States of America)
//@p1 as a getter for @GEORGE and @USA
(@p1 (@GEORGE) was the first President of the (@USA).)
//@p1 recast as 2-form with no dependencies
(@p1 (@GEORGE George Washington) was the first President of the (@USA United States of America).)