::= (
@
key ( machine | world | stream | view | canon | atom | selector | value | transform )* hash? comment? )
The fundamental unit of storage is the atom, written (@ key
). The following is an MSL expression that sets a value of Walt Disney
for an atom with the key WALT
. When working with atoms in the @
namespace, you can put the key right up against the @
sign, and this is the most common syntax. To set a value, you put the value after the key.
(@WALT Walt Disney) ⇒ Walt Disney
An MSL expression like this which contains a value returns the value it is given. In a typical viewer, The name "Walt Disney" would appear in paragraph text in place of this atom. It could also be used to identify this atom in other areas of the user interface.
atom-form ::= (
namespace key (atom-form selector value transform)* hash? comment?)
;
namespace ::= @
| c
| v
| s
| w
| m
In Mimix, all data is stored in atoms in MSL expressions. An atom's current value is maintained in the hash table and its previous values are written in the MSL stream.
MSL expressions act on data stored in atoms. There are generally two parts to an atom: a key-sequence and a value. The key-sequence is comprised of the atom's namespace , the atom's own key , and the metadata-key , if any. This key-sequence is the operand. It gives the current value from the hybrid database. The remainder of the MSL expression is a new value, including any other atoms, values, or transforms it contains. This second portion of the expression is the operator. It tells what to do at the location.
The general rule is that if only a key-sequence is supplied, we get the value of that key-sequence from the hash table. If a value is supplied, we set the key-sequence in the hash table to that value.
While it would be possible to construct the entire language using only atom-based expressions, the resulting "atom soup" would be hard to be read. Instead, a hierarchy of namespaces is enforced to help users and the system find a context for values. A special namespace, the canon, provides a layer of value protection over all the other namespaces. Together, these namespaces are searched in a particular order according to the evaluation rules in order to find the current value of an atom or its metadata.
To retrieve a value which has be set previously in the atom, in canon, or in a view, stream, world, or machine, we only have to write the key:
(@WALT) ⇒ Walt Disney
To change an atom's value going forward, we write another expression with the same key and a new value:
(@EPCOT EPCOT) ⇒ EPCOT
(@EPCOT) ⇒ EPCOT
(@EPCOT Epcot Center) ⇒ Epcot Center
(@EPCOT) ⇒ Epcot Center
The first time (@EPCOT)
gets a value, it is the word "EPCOT." Recalling (@EPCOT)
by key alone returns this same value. The next line changes the value of (@EPCOT)
to "Epcot Center." The next time the atom is recalled by key alone we get this most recent value.
Values are recorded in the @
expressions in MSL itself. The rationale behind this is that text values are not canonical and might change throughout a document. In the same paper, Disney, Walt, Walt Disney, Mr. Disney, and even words like "he" or "him" can all refer to the same atom with different text values appearing inline. The MSL records the inline value at the moment in the stream where it is used while the key holds the ongoing reference to the same atom.
If an atom is edited in any way, a new copy is recorded with the same key. The old copy is kept but future views refer to the new copy. References in between the old and new atom in MSL text refer to the old one. The sample text in the previous section might be edited and recorded thus:
(@p1 The (@EPCOT:long) was an unfinished concept developed by (@WALT), the last one he worked on before his death in (@1966). Its purpose was to stimulate American industry to develop new ideas for urban living. The city was planned to be a company town near (@ORLANDO:city-state). The original property became the (@WDW:name:) in (@1971) and a (@EPCOT) theme park based on the idea opened in (@1982).)
This version has moved around several parts and deleted others but the same atoms still exist. The opening year of Disney World was corrected to 1971 but the previous (@1972)
atom still exists. Furthermore, the entire previous paragraph (@p1)
still exists earlier in the stream.
If we type another paragraph, another paragraph atom (@p2)
is created next in the stream.
(@p2 In the early (@1960:poss), entertainment industry magnate (@WALT), who by this time had many grandchildren, began to worry about the future of the world they would inhabit. He worried especially about modern cities which he believed were hectic, disorganized, dirty, and crime-ridden, a far cry from his clean and controlled (@DISNEYLAND) in (@CALIFORNIA).)
An edit to an existing paragraph is recorded as a new version of the atom with the same key, in linear sequence in the stream in the order in which it happened.
An MSL expression must always return a value. Any MSL expression which results in no value (a Lisp NIL) cannot be parsed and also results in all its containing expressions resulting in NIL and therefore stopping interpretation. By definition, an MSL expression cannot set or get a null value, as empty results are not meaningful in the context of parsing narrative text. No MSL expression can set a value to null and no MSL expression can result in the return of a NIL or null value.
(@TDR) ⇒ NIL. @TDR doesn't have a value.
(@TDR Tokyo Disneyland Resort) ⇒ Tokyo Disneyland Resort
(@TDR) ⇒ Tokyo Disneyland Resort. @TDR has a value from last expression.
While it is not possible to directly remove a value or metadata from an expression, it is possible to re-write the expression without the pieces that you want removed. Providing a new value for an atom (or atom-form like canon, view, etc.) always removes the old value and any previous metadata from that atom. If the metadata is a datatype selector or format transform, these are preserved separately and can be re-applied to the atom or another atom later.
(@WALT Walt Disney /Walt/ Walter Elias) ⇒ Walter Elias Disney. Regex selector applied.
(@WALT) ⇒ Walter Elias Disney. Regex selector preserved.
(@WALT /Walt Disney/ WED) ⇒ WED. New regex selector erases the old.
(@WALT Walt Disney) ⇒ Walt Disney. Value supplied. Regex removed.
(@DONALD Donald Duck (d character)) ⇒ Donald Duck. Datatype selector applied.
(@DONALD) ⇒ Donald Duck. Datatype selector preserved.
(@DONALD (d animated) (d duck)) ⇒ Donald Duck. New datatypes erase the old.
(@DONALD) ⇒ Donald Duck. New datatypes preserved.
(@DONALD Huey's Uncle) ⇒ Huey's Uncle. Value supplied. Datatypes removed.