::= (
c
key ( canon | atom | selector | value | transform )* hash? comment? )
Atoms can be wrapped in a canon expression to provide a layer of protection against future changes. Here, periodic table atoms are set inside a canon expression (c periodic-table)
:
(c periodic-table
(@H hydrogen :no 1 :symbol H :weight 1.008)
(@Li lithium :no 3 :symbol Li :weight 6.94)
(@Na sodium :no 11 :symbol Na :weight 22.990))
This canon can be applied to atoms which use these keys by placing the (c periodic-table)
expression in a view before the paragraphs that use it. Thereafter, the canonical data is recalled and used in place of references such as (@H)
when the paragraph is displayed.
(v science-paper
(c periodic-table)
(@sample-sentence (@H) is the first element (atomic number (@H:no)) in the periodic table and the lightest, with an atomic weight of (@H:weight).))
The (@sample-sentence)
atom would render like this in the viewer:
Hydrogen is the first element (atomic number 1) in the periodic table and the lightest, with an atomic weight of 1.008.
Basic sentence formatting, such as capitalizing the H in hydrogen or providing proper spacing between the period at the end of the sentence and the next sentence that might appear in the narrative can be performed by the viewer.
Values provided for atoms which are protected by canon only overwrite the specific instance in which the value is provided, not any other references to the atom going forward. Future references to the atom's value reset to the canonical values.
(v science-paper
(c periodic-table)
(@p1 The atomic weight of (@Li) is about (@Li:weight 7).)
(@p2 The exact atomic weight of (@Li) is (@Li:weight)))
(@p1) ⇒ The atomic weight of Lithium is about 7.
(@p2) ⇒ The exact atomic weight of Lithium is 6.94.
Here, the last invocation of (@Li:weight)
recalls the canonical value, not the value supplied in the previous paragraph.
In several examples in the wiki, we assume a user has typed or opened some new text which matched existing metadata. A part of that metadata might look like this:
(c disney-world
(@EPCOT EPCOT :long Experimental Prototype Community of Tomorrow)
(@WALT Walt Disney :born 1901-12-5)
(@WDW Walt Disney World :long Walt Disney World Resort :opened 1971))
Dates such as Walt Disney's birthday or the opening day of WDW are stored as text which can be interpreted as a date through the use of format expressions.
The Experimental Prototype Community of Tomorrow (EPCOT) was an unfinished concept developed by Walt Disney. Its purpose was to be a "real city that would never cease to be a blueprint of the future," designed to stimulate American industry to develop new ideas for urban living. The city was envisioned as a company town near Orlando, Florida. After his death in 1966, the property became the Walt Disney World Resort in 1972 and a theme park based on the idea opened in 1982.
(@p1 The (@EPCOT:long) ((@EPCOT)) was an unfinished concept developed by (@WALT). Its purpose was to be a "real city that would never cease to be a blueprint of the future," designed to stimulate American industry to develop new ideas for urban living. The city was envisioned as a company town near (@ORLANDO:city-state). After his death in (@1966), the property became the (@WDW) in (@1972) and a theme park based on the idea opened in (@1982).)
The viewer matches words and phrases in the incoming text to the canon it already knows, replacing the literal text with MSL atoms.
New text which is typed or brought into a view creates a new atom. In this case, the viewer called it (@p1)
. It represents this entire paragraph of typed text. Inside the paragraph, the syntax (@EPCOT:long)
pulls the value of the :long
key from the metadata associated with the (@EPCOT)
atom in the canon, which is the project's long name, "Experimental Prototype Community of Tomorrow." The (@EPCOT)
atom by itself pulls the value itself, "EPCOT," from the canon.
A year atom can be specified as (@1966)
. These are used in the creation of timelines.
Canon can be changed going forward by calling another (c) expression with the same key. Going backwards in the stream, the old value still exists and older view expressions will show it that way when referred to in another atom like a paragraph.
To write a screenplay with three main characters, we might store some facts about them in canonical metadata:
(c characters
(@matthew :name Matthew Comlin :age 34 :occupation ramp worker)
(@brie :name Brie Summers :age 20 :occupation circle k)
(@janitor :name Janitor :age 63 :occupation janitor))
We can apply this metadata to new text using a view:
(v working-draft
(c characters)
(@p1)(@p2)(@p3)(@p4))
If we decide to change Matthew's last name, we can change the canonical metadata with another expression:
(c characters (@matthew :name Matthew Collins))
This generates another view expression because, going forward, we will want to see the new last name. This is exactly the same view expression as before but it refers to the last value of (c characters) which was defined just before it, as opposed to the previous view which refers to the value before that.
(v working-draft
(c characters)
(@p1)(@p2)(@p3)(@p4))
The atom (@p1)
here having no value retrieves the last value it had inside this view, just as (c characters)
retrieves the last value it had inside this view. The entire construct from (c characters)
to (@p4)
becomes the new value of (v working-draft)
.
On-screen representations, printouts, etc. of the text after this view expression would show Matthew Collins whenever (@matthew:name)
was accessed.
We've seen how multiple (c)
expressions can apply to the atoms in a view and this can be used to separate different data types, but multiple canonical data can also apply to the same type of information in different views. There cannot, however, be two canonical values with the same key applied to the same atom at the same time. For that, we would need create a separate view.
If we copy the view (made easy by the viewer), we can give it its own name. Then, two views of the same text can appear on screen simultaneously and refer to different canon. These can be shown in parallel windows, pop-ups, or whatever other UI device is desired or available in the viewer.
We can look at the same document using two different dictionaries or two different sets of technical specifications. Two separate views each link together the same text (a series of paragraph atoms in its own view) with a different set of reference materials (canon).
(s burroughs-intro
(c algol-60 (@p1 …) (@p2 …))
(c algol-68 (@p1 …) (@p2 …))
(v intro-to-algol (@p1) (@p2))
(v algol-intro-60
(c algol-60)
(v intro-to-algol))
(v algol-intro-68
(c algol-68)
(v intro-to-algol))
(v published-book
(v algol-intro-60))
(v published-book
(v algol-intro-68)))
The same intro document can be viewed simultaneously using two different sets of reference materials, like the Algol 60 set and the Algol 68 set. Either of the versions could be published under the same atom.