[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.1.4 Symbols
Symbols are case sensitive and the reader is case sensitive too. So:
(eq? 'foo 'FOO) ⇒ #f (eq? (string->symbol "foo") (string->symbol "FOO")) ⇒ #f
Symbols may contain special characters (such as #\Newline or #\Space).
Such symbols that have to be read must be written: |[^]+|
. The
function write
uses that notation when it encounters symbols
containing special characters.
(write 'foo) ⇒ foo (write 'Foo) ⇒Foo (write '|foo bar|) ⇒ |foo bar|
- procedure: symbol? obj
- procedure: symbol->string symbol
Returns the name of the symbol as a string. Modifying the string result of
symbol->string
could yield incoherent programs. It is better to copy the string before any physical update. For instance, don’t write:(string-downcase! (symbol->string 'foo))
See (R5RS)r5rs.info, for more details.
but prefer:
(string-downcase (symbol->string 'foo))
- procedure: string->symbol string
- bigloo procedure: string->symbol-ci string
- bigloo procedure: symbol-append symbol …
String->symbol
returns a symbol whose name is string.String->symbol
respects the case of string.String->symbol-ci
returns a symbol whose name is(string-upcase string)
.Symbol-append
returns a symbol whose name is the concatenation of all the symbol’s names.
- bigloo procedure: gensym [obj]
-
Returns a new fresh symbol. If obj is provided and is a string or a symbol, it is used as prefix for the new symbol.
- bigloo procedure: genuuid
-
Returns a string containing a new fresh Universal Unique Identifier (see http://fr.wikipedia.org/wiki/Universal_Unique_Identifier).
- bigloo procedure: symbol-plist symbol-or-keyword
Returns the property-list associated with symbol-or-keyword.
- bigloo procedure: getprop symbol-or-keyword key
-
Returns the value that has the key
eq?
to key from the symbol-or-keyword’s property list. If there is no value associated with key then#f
is returned.
- bigloo procedure: putprop! symbol-or-keyword key val
Stores val using key on symbol-or-keyword’s property list.
- bigloo procedure: remprop! symbol-or-keyword key
Removes the value associated with key in the symbol-or-keyword’s property list. The result is unspecified.
Here is an example of properties handling:
(getprop 'a-sym 'a-key) ⇒ #f (putprop! 'a-sym 'a-key 24) (getprop 'a-sym 'a-key) ⇒ 24 (putprop! 'a-sym 'a-key2 25) (getprop 'a-sym 'a-key) ⇒ 24 (getprop 'a-sym 'a-key2) ⇒ 25 (symbol-plist 'a-sym) ⇒ (a-key2 25 a-key 24) (remprop! 'a-sym 'a-key) (symbol-plist 'a-sym) ⇒ (a-key2 25) (putprop! 'a-sym 'a-key2 16) (symbol-plist 'a-sym) ⇒ (a-key2 16)
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.