Many of MSL's most potent abilities can be exercised through rewrtiting. In its simplest form, rewriting involves three steps:
The MSL viewer application can examine the previous values of the hybrid database, as these are stored as MSL text. It can offer a user interface for behaviors which might be desired or expected over the MSL that already exists in the stream. This document will show several examples of where this is useful.
The human corrollary is that, when listening to a story from friends, we can infer that every invocation of the friend's name refers to the same person. Likewise, by examining the MSL text, a viewer can determine where atoms appear and where they are repeated. Also like a human listener, every MSL expression "knows" what's in the expressions before it, but not what's in any still to come.
Only the author of a text can know its intent, but a viewer application can offer several options and present these to the user in simple forms. For each of the examples here, we'll show the intent of the action.
Once the intent is known, any aspect of the MSL can be changed going forward by writing new MSL. If a dependency on previous MSL is desired, the new expressions can be
1-form or short form. If a portable version is desired, the new MSL can be written in
2-form without dependencies. The invocation of the new MSL itself is recorded in the stream and therefore reversible.
Intent: Revert all or part of a change to the hash table.
Any MSL expression can be rewound to any previous value by examining the stream backwards to find the last
setter for each value set by the expression being undone. In other words, to undo a setter for
(@WALT:birthday), we rewrite the last value of
(@WALT:birthday) from the MSL text. If one expression sets multiple values, these can all be rewound by rewriting the expression with all the previous values.
Because undo (and all other changes) are achieved by rewriting, the undo does not have to undo every aspect of a setter. A viewer application could present a user interface which allowed undoing of some aspects of a change while preserving others.
(@p1 Today's word processor styles are closely related to early aspects of lead type, such as (@BOLD bold (f bold)) and (@ITALIC italic (f italic)). (f color black) (f font-size 12 pt)) (@p1 (f color blue)) (@p1 (f font-size 14 pt))
In a typical word processor, undoing back to step 2 would also wipe out the font size change in line 3 when the user's intent was only to remove the color blue. In MSL,
(@p1) could be rewritten to preserve only the desired elements by examining all of the setters for the atom in the MSL text and allowing the user to chose which should be rewritten.
(@p1 Today's word processor styles are closely related to early aspects of lead type, such as (@BOLD bold (f bold)) and (@ITALIC italic (f italic)). (f color black) (f font-size 14 pt))
Intent: Preserve important information as it's gleaned from multiple documents and sources.
Canonization, or lifting atoms into the canon namespace, is the most common form of rewriting. It provides a form of reset protection in that canonical values are always returned from getter expressions (in preference to the hash table's last value) if they have been set.
In the following example, all of the atoms in the paragraph text can be canonized to preserve their values by rewriting the same atoms inside a canon expression.
(@p1 The (@ANTHROPIC Anthropic principle) is a philosophical world view which says that, in order for the universe to allow human observation, it must have been compatible with sentient life and consciousness from its inception. The (@ANTHROPIC) is proposed as one explanation for the (@DIMENSIONLESS-CONSTANTS dimensionless constants) in the (@STANDARD-MODEL Standard Model of Physics).) (@p2 Today, the (@STANDARD-MODEL) requires (@STANDARD-MODEL :dimensionless-constants 25) of these (@DIMENSIONLESS-CONSTANTS).)
All of the values and metadata gleaned from the embedded atoms in these two paragraph atoms can be lifted into the canon namespace and preserved for future invocations, with the exact same results for
(v quantom-story (c quantum-canon Quantum Mechanics & Philosophy (@ANTHROPIC Anthropic principle) (@DIMENSIONLESS-CONSTANTS dimensionless constants) (@STANDARD-MODEL Standard Model of Physics :dimensionless-constants 25)) (@p1 The (@ANTHROPIC) is a philosophical world view which says that, in order for the universe to allow human observation, it must have been compatible with sentient life and consciousness from its inception. The (@ANTHROPIC) is proposed as one explanation for the (@DIMENSIONLESS-CONSTANTS) in the (@STANDARD-MODEL).) (@p2 Today, the (@STANDARD-MODEL) requires (@STANDARD-MODEL:dimensionless-constants) of these (@DIMENSIONLESS-CONSTANTS).))
Intent: Move data into a higher namespace in order to group it with other atoms and share values.
Lifting involves rewriting an atom or atom form into a higher namespace, thereby making its values available to other atoms inside the higher space. In the following example, an author consults two documents and writes new notes. Later, these are lifted into a
(w) world in order to begin a new project.
(s sunday-research :date 9/6/2020 :author David Bethune (v classical-physics Classical physics :wiki [https://en.wikipedia.org/wiki/Classical_physics]) (v modern-physics Modern physics :wiki [https://en.wikipedia.org/wiki/Modern_physics] :img [https://en.wikipedia.org/wiki/Modern_physics#/media/File:Modernphysicsfields.svg] (d img svg)) (v quantum-physics-notes What is the connection between clasical and modern physics? (@p1 (@classical-mechanics Classical mechanics) deals with objects larger than an atom or molecule which are moving far slower than the speed of light.) (@p2 (@relativistic-mechanics Relativistic mechanics) deals with objects larger than an atom or molecule which are moving at a speed approaching the speed of light.) (@p3 (@quantum-mechanics Quantum mechanics) deals with objects smaller than an atom or molecule which are moving at speeds far slower than the speed of light.) (@p4 (@quantum-field-theory Quantum field theory) deals with objects smaller than an atom or molecule and moving at speeds approaching the speed of light.))) (w quantum-research :date 9/7/2020 :author David Bethune (s sunday-research (v classical-physics)) (s sunday-research (v modern-physics)) (v classical-notes (s sunday-research (v quantum-physics-notes (@p1) (@p2))) (v modern-notes (s sunday-research (v quantum-physics-notes (@p3) (@p4))))
In line 16, a new
(w) world is created which combines the documents from
(s sunday-research) and the user's notes. The notes are also reorganized in the rewriting in order to group them into
Intent: Combine information about the same atom from various sources, choosing what should be preserved and what discarded.
Merging takes place when two atom forms with the same key contain contradictory or overlapping information. In general, merge conflicts can be resolved in three ways:
The viewer's user interface can offer these as options, then rewrite the MSL as needed.
Intent: When two definitions of an atom conflict, to entirely choose one over the other.
When the definition of an atom conflicts between containing atom forms, a viewer can offer to choose one definition over the other by rewriting the chosen definition.
(w kennedy-assassination Who Shot JFK? (c (@JFK John F. Kennedy)) (v warren-commission The Warren Commission Report :whodunit (@JFK :killer Lee Harvey Oswald)) (v conspiracy-book JFK and the CIA :whodunit (@JFK :killer Unknown Mobster)) (s jfk-story JFK: The Real Story :author TBD (c (@JFK John F. Kennedy :killer Unknown Mobster))) (s warren-story The Warren Report: A Recreation :author Discovery Networks (c (@JFK John F. Kennedy :killer Lee Harvey Oswald))) (s jfk-story (@JFK:killer)) â‡’ Unknown Mobster (s warren-story (@JFK:killer)) â‡’ Lee Harvey Oswald
In line 7, The JFK Story rewrites
(@JFK) to fully ignore the
:killer specified in line 3 and replace it with the definition in line 4.
In line 10, The Warren Report: A Recreation fully ignores
(@JFK:killer) in line 4 and replaces it with the value from line 3.
Intent: When two definitions of an atom conflict, to keep some of the values (the atom's value and/or any of its metadata values) and reject others.
The viewer user interface can allow the user to individually choose which values and subatomic values from an atom are selected for a merge. Some of these options can be determined algorithimically, such as keeping all the old values if they conflict while adding any new ones:
(v one-walt-story (@p1 (@WALT Walter Elias Disney :birthplace Chicago, IL) was an American inventor and entrepreneur.))) (v another-walt-story (@p3 (@WALT Walt Disney :birthplace USA :creator (@DISNEYLAND Disneyland)) was the creator of (@WALT:creator).))) (c disney-canon (@WALT Walter Elias Disney :birthplace Chicago, IL :creator (@DISNEYLAND Disneyland)))
In this example, the viewer could offer to keep all the old values for
(@WALT) from line 2 (ignoring the new settings in line 5) while adding the new value
(@WALT:creator) also found on line 5. The rewrite on line 8 shows the result of expressing this user intent in MSL.