A symbol can be introduced into the system with the intern
function.
| intern name | Function |
intern returns the interned symbol with the name name.
name can be either an Lpp String or a char* string. The
name argument can be composed of any characters unless it is a
char* in which case the character 0 is not allowed. If the
symbol name has not been interned yet then it is interned
first.
Lpp symbol are are case sensitive. So, for example, Red and
red are two different symbols.
The S macro provides a short hand for entering symbols.
| S name | Macro |
This macro returns an Lpp Symbol with print name name. The name argument is not escaped with double quotes. Note that for some sequence of characters chars
S(chars) == intern("chars")
For example:
let sym1 = S(red);
let sym2 = intern("red");
sym1 == sym2 => 1
eq(sym1, sym2) => t
Note that creating a symbol with S in an Lpp program is not the
same as quoting a symbol in a Common Lisp program. In a Common Lisp
program the quoted symbol causes intern to be called only on
reading the program, however in a C++ program intern will be
called when the code is running. So for example
let sym1 = S(red);
let list1 = list(sym1, sym1);
is slightly more efficient than
let list1 = list(S(red), S(red));
In both cases only one Symbol red is created, but in the second
case intern is called twice, the second time simply returning
the already interned symbol red.
| unintern symbol | Function |
unintern removes the symbol symbol from the system. It
returns nil.