2.2 Virtual Strings

The data to be sent or to be written consists of a sequence of integers, atoms, floats, and strings. If only strings were allowed to be sent as information, the data would have to be transformed into a string. This would be clumsy and inefficient with regard to both space and time.

Mozart uses virtual strings for this purpose instead. A virtual string is either an atom, a float, an integer, a string, or a tuple with label '#', whose subtrees are virtual strings themselves. For instance,


is a virtual string. In the above example it is quite clear, that # stands for concatenation (i. e., for virtual concatenation).

There is predefined functionality for virtual strings, like testing, by IsVirtualString, converting to a string, by VirtualString.toString, and changing of signs, by VirtualString.changeSign. The latter procedure is quite important, because

{Browse 12#(2#fast#4#"U")#~3.1415}

reveals that the usual unary minus sign (i. e., -) is used rather than the Oz operator ~.

The procedure VirtualString.changeSign provides the possibility to choose any virtual string as minus sign in numbers. It takes as input arguments two virtual strings, and substitutes every occurrence of the - character as a unary minus sign in numbers of the first argument by the second argument. For example,

{VirtualString.changeSign 12#(2#fast#4#"U")#~3.1415 '~'}

returns the virtual string with the Oz-style unary minus sign.

Note that in order to display virtual strings in readable form in the Oz Browser, you have to configure the Representation, Type option, see also ``The Oz Browser''. In the following we assume that the Browser is configured for displaying virtual strings.

Christian Schulte
Version 1.4.0 (20080702)