UTL Name System
Universal Text Namespaces
Namespaces
The Name System forms a hierarchy of identifiers. For example the identifier "T" has a child identifier "A".
=T
=T.A
This is the same as:
=T { =A }
This is not the same as:
=T { =.A }
which means:
=T
=A
The next level of the hierarchy has implicitly a new name space, as seen above. If you want to merge the current level with some other name space:
=T {
=(.)
=A
}
Through =(.) the child and the parent level share the namespace, the above being the same as:
=T
=A
The =( ) directive can only appear on top of a level before any =name definition. There can be more than one =( ) directive. The symbols from the second name space on can be referenced, but introducing new symbols at the child level will introduce it just on the first parent level.
The difference of the name system in respect to the familiar os file systems is that you can refer to upper levels by name:
=T { =A { =B { =T } } }
Here the second T refers to the first one (the parents parent).
Alternate Namespaces
Each name is not bound 1:1 to a particular unit. It is possible to refer to the same unit with different names and it is possible for a name to refer to different units. It is possible to define a Name System, consisting of pairs (identifier, unit). One can choose a Name System to be used when feeding a text and when retrieving a text extract.
This has of course tief impact on the text implementation.
=name can no more being hard-coded together with the text structure but names are strings (binary data) associated with a particular role.
^ unit {
^ NAME : string
}
^ T {
^ short-name ~ NAME
^ long-name ~ NAME
}
A line such as =a ~T is being parsed as:
~ T {
~ short-name a
}
When parsing and when outputing units or in general getting names one must say, which name system they come from.
[ NAME => short-name
=a ~ T
]
Note that all names above, ”T“, ”short-name“, ”NAME“, ”string“, ”unit“ are in a particular name system and can be expressed in other ones.
There must be a ”default name system“ for each type, perhaps implicit. There must be a fall back mechanism, if for a particular unit there is no name for a particular name system one gets the name in another one. Fallback order can be determined for a single query.
Name Versions
In a simple Text Engine one cannot make changes to the text, everything is once fed and remains fixed. A Text Repository is not intended to remove parts of texts that once existed. One can provide such functionality through name versions. A single name can refer to the latest version of a text unit. To change a unit is internally resolved as creating a new version of its name. An unqualified unit name refers to the last state, but one can refer to a particular previous version if one wants to. That is of course a deep change in the text implementation, because one cannot save Id's of the referred units, but one must save names instead and resolve them at run time whenever they are needed.
Versioning could work this way.
Syntax
The line:
=T;*
tells the compiler that a new version of the name T has to be instanciated. The name T has after that no contents, all following references to T refer to this newly created version.
You can refer to a specific version with its version number.
=T;12
The version numbers are automatically set. The first version is T;1 the next one T;2 and so on.
If no version number is explicitly mentioned, one gets the last one.
A.B.C;12 the version number refers to C.
A;5.B;2.C;12 the version numbers refer to each level.
It should be considered referring to versions by commit date and time or by labeling them, too.
Name conflicts
After creating a new version it must be ensured that the system remains coherent.
If T :A and you say T;* :B this should not compile, if :B is not a child of A and at some place one relies on T being an :A.
Name Aliases
To import a symbol into the current name space one writes:
=Q ==(T.A)
This defines Q on the current name space as a reference to T.A.
The name T.A is evaluated at compile time. You can get a name reference which is resolved at run time with:
=Q =>(T.A)

