symbols.texi (1869B)
1 @c -*-texinfo-*- 2 @setfilename ../src/symbols 3 4 @node Symbols, Control, Equivalence, Top 5 @comment node-name, next, previous, up 6 7 @chapter Symbols 8 @cindex symbols 9 @c TODO add xref to eq?, identifiers, etc 10 Two symbols are eq? iff they have the same external 11 representation. Symbols are immutable, and the symbol type is 12 encapsulated. The external representations of symbols are usually 13 identifiers. However, symbols with other external representations may 14 @c TODO add xref to string->symbol 15 be created. Symbols whose external representation is enclosed within 16 ``|'' (that is ``| ... |'') can contain any character supported by 17 klisp, ``|'' and ``\'' can be included by escaping them with a leading 18 ``\'' (that is ``\|'' and ``\\''). Characters in symbols can also be 19 specified with a unicode hex escape by using the syntax ``\x<hex 20 codepoint>;''. This works whether using the ``| ... |'' syntax or 21 not. 22 23 @deffn Applicative symbol? (symbol? . objects) 24 The primitive type predicate for type symbol. @code{symbol?} 25 returns true iff all the objects in @code{objects} are of type symbol. 26 @end deffn 27 28 @deffn Applicative symbol->string (symbol->string symbol) 29 Applicative @code{symbol->string} returns the name of @code{symbol} 30 as a string. The string returned is immutable. 31 @end deffn 32 33 @deffn Applicative string->symbol (string->symbol string) 34 Applicative @code{string->symbol} returns the symbol with name 35 @code{string}. The symbol is always interned, which means, that it is 36 always the case that: 37 @example 38 (eq? <symbol> (string->symbol (symbol->string <symbol>))) 39 @result{} #t 40 @end example 41 @c TODO add xrefs for external representation 42 @code{string->symbol} can create symbols whose external 43 representation aren't identifiers. klisp uses the r7rs external 44 representation for such symbols and so all symbols can be written and 45 read back. 46 @end deffn