5 Pattern text and wtext

Pattern text represents 8-bit ASCII texts.

Pattern wtext represents 16-bit UniCode texts. For details see the library basiclib/wtext.bet. Operations supporting conversion between text and wtext are available. In a future version of BETA, wtext may replace text.

5.1 String Literals as References

The pattern Text enters and exits a char-repetition. This means, that a text may be initialized using constant strings as follows:

t: @text;
do 'hello' -> t;

Many operations involving texts, however, takes references to texts as enter/exit parameters. This is mainly for efficiency reasons.

To allow easy invocation of such operations on string literals, the following is also allowed:

t: ^text;
do 'hello' -> t[];

The semantics of this is, that a text object is instantiated, initialized by the constant string, and finally assigned to the text reference. It thus corresponds to the following code:

do &text[] -> t[];
   'hello' -> t

5.2 Special Characters in String Literals

The following special characters are allowed in BETA string literals.

\a alert (bell) character

\b backspace

\f formfeed

\n newline

\r carriage return

\t horizontal tab

\v vertical tab

\\ backslash

\? question mark

\' single quote

\" double quote

\ooo octal number

\ooo can also be \o or \oo, if the character immediately following \o or \oo respectively, is not a digit.

Previous versions of BETA has allowed '' to represent a quote ' in strings as in 'Tom''s Cottage'. This is no longer allowed. Quote must be represented using \' as in:

'Tom\'s Cottage'

5.3 Text Literal Concatenation

A text literal cannot contain newlines. Alternatively a text literal may be written as a sequence of strings separated by white space as in:
'Lisa Nelson, '
'2454 West Street, '
'Palo Alto, CA 94304' -> T[]
This corresponds to:
'Lisa Nelson, 2454 West Street, Palo Alto, CA 94304' -> T[]

5.4 Text literals

Text literals like 'Hello' may be considered as abbreviations of char repetition constructors like ('H','e','l','l','o'). Consider:
Q: [1]@char

The evaluation:

'Hello' -> Q
may considered as an abbreviation for:
('H','e','l','l','o') -> Q


BETA Language Modifications - Reference Manual
© 1999-2004 Mjølner Informatics
[Modified: Sunday October 22nd 2000 at 0:53]