* New version of IRM New version of the IRM, updated to Medley. * moved to docs/medley-irm as discussed
85 lines
50 KiB
Plaintext
85 lines
50 KiB
Plaintext
INTERLISP-D REFERENCE MANUAL
|
||
SYMBOLS (LITATOMS)
|
||
(NIL (Chapter) NIL NIL NIL NIL)2. SYMBOLS (LITATOMS)
|
||
3
|
||
|
||
A litatom (for ªliteral atomº) is an object that conceptually consists of a print name, a value, a function definition, and a property list. Litatoms are also known as ªsymbolsº in Common Lisp. For clarity, we will use the term ªsymbolº.
|
||
A symbol is read as any string of non-delimiting characters that cannot be interpreted as a number. The syntactic characters that delimit symbols are called ªseparatorº or ªbreakº characters (see Chapter 25) and normally are space, end-of-line, line-feed, left parenthesis (, right parenthesis ), double quote ", left square bracket [, and right square bracket ]. However, any character may be included in a symbol by preceding it with the character %. Here are some examples of symbols:
|
||
A wxyz 23SKIDDOO %]
|
||
Long% Litatom% With% Embedded% Spaces
|
||
(LITATOM(LITATOM (Function) NIL NIL ("2") 1) X) [Function]
|
||
Returns T if X is a symbol, NIL otherwise. Note that a number is not a symbol.
|
||
(LITATOM NIL) = T
|
||
(ATOM (ATOM% (Function) NIL NIL ("2") 1)X) [Function]
|
||
Returns T if X is an atom (i.e., a symbol or a number) or NIL (e.g. (ATOM NIL) = T); otherwise returns NIL.
|
||
Warning: (ATOM X) is NIL if X is an array, string, etc. In Common Lisp, the function CL:ATOM is defined equivalent to the Interlisp function NLISTP.
|
||
Each symbol has a print name, a string of characters that uniquely identifies that symbol: Those characters that are output when the symbol is printed using PRIN1, e.g., the print name of the symbol ABC%(D consists of the five characters ABC(D.
|
||
Symbols are unique: If two symbols print the same, they will always be EQ. Note that this is not true for strings, large integers, floating-point numbers, etc.; they all can print the same without being EQ. Thus, if PACK or MKATOM is given a list of characters corresponding to a symbol that already exists, they return a pointer to that symbol, and do not make a new symbol. Similarly, if the read program is given as input a sequence of characters for which a symbol already exists, it returns a pointer to that symbol.
|
||
Symbol names are limited to 255 characters. Attempting to create a larger symbol will cause an error: Atom too long.
|
||
Sometimes we'll refer to a ªPRIN2-nameº. The PRIN2-name of a symbol is those characters output when it is printed using PRIN2. So the PRIN2-name of the symbol ABC%(D is the six characters ABC%(D. The PRIN2-name depends on what readtable is being used (see Chapter 25), since this determines where %s will be inserted. Many of the functions below allow either print names or PRIN2-names to be used, as specified by FLG and RDTBL arguments. If FLG is NIL, print names are used. Otherwise, PRIN2-names are used, computed with respect to the readtable RDTBL (or the current readtable, if RDTBL = NIL).
|
||
(MKATOM(MKATOM (Function) NIL NIL ("2") 2) X) [Function]
|
||
Creates and returns a symbol whose print name is the name as that of the string X or, if X is not a string, the same as that of (MKSTRING X). Examples:
|
||
(MKATOM '(A B C)) => %(A% B% C%)
|
||
(MKATOM "1.5") => 1.5
|
||
Note that the last example returns a number, not a symbol. It is a deeply-ingrained feature of Interlisp that no symbol can have the print name of a number.
|
||
(SUBATOM(SUBATOM (Function) NIL NIL ("2") 2) X N M) [Function]
|
||
Returns a symbol made from the Nth through Mth characters of the print name of X. If N or M are negative, they specify positions counting backwards from the end of the print name. Equivalent to (MKATOM (SUBSTRING X N M)). Examples:
|
||
(SUBATOM "FOO1.5BAR" 4 6) => 1.5
|
||
(SUBATOM '(A B C) 2 -2) => A% B% C
|
||
(PACK(PACK (Function) NIL NIL ("2") 2) X) [Function]
|
||
If X is a list of symbols, PACK returns a single symbol whose print name is the concatenation of the print names of the symbols in X. If the concatenated print name is the same as that of a number, PACK returns that number. For example:
|
||
(PACK '(A BC DEF G)) => ABCDEFG
|
||
(PACK '(1 3.4)) => 13.4
|
||
(PACK '(1 E -2)) => .01
|
||
Although X is usually a list of symbols, it can be a list of arbitrary objects. The value of PACK is still a single symbol whose print name is the concatenation of the print names of all the elements of X, e.g.,
|
||
(PACK '((A B) "CD")) => %(A% B%)CD
|
||
If X is not a list or NIL, PACK generates the error Illegal arg.
|
||
(PACK* X1 X2... XN(PACK* (Function) NIL NIL ("2") 2) ) [NoSpread Function]
|
||
Version of PACK that takes an arbitrary number of arguments, instead of a list. Examples:
|
||
(PACK* 'A 'BC 'DEF 'G => ABCDEFG
|
||
(PACK* 1 3.4)) => 13.4
|
||
(GENSYM(GENSYM (Function) NIL NIL ("2") 2) PREFIX ÿÿ |