For Gauche 0.9.14Search (procedure/syntax/module):

Next: , Previous: , Up: Core library   [Contents][Index]

6.7 Symbols

Builtin Class: <symbol>

A class for symbols.

Reader Syntax: |name|

[R7RS] Denotes a symbol that has weird name, including the characters that are not usually allowed in symbols. It can also include hex-escaped characters.

;; A symbol with spaces in its name
'|this is a symbol| ⇒ |this is a symbol|

;; Unicode codepoint can be used following backslash-x escape,
;; and terminated by semicolon.
'|\x3bb;| ⇒ λ

If the interpreter is running in case-insensitive mode, this syntax can be used to include uppercase characters in a symbol (see Case-sensitivity).

Reader Syntax: #:name

Denotes uninterned symbol. Uninterned symbols can be created by gensym or string->uninterned-symbol.

Uninterned symbols are mainly for legacy macros to avoid variable conflicts. They are not registered in the internal dictionary, so such symbols with the same name can’t be eq?.

(eq? '#:foo '#:foo) ⇒ #f
(eq? '#:foo 'foo) ⇒ #f

To preserve eq?-ness of uninterened symbols, you need to use write-shared which shows shared structures.

(write-shared (let1 s '#:foo (list s s)))
  ⇒ prints (#0=#:foo #0#)

(write-shared (let ((s '#:foo) (t '#:foo)) (list s t s t)))
  ⇒ prints (#0=#:foo #1=#:foo #0# #1#)
Function: symbol? obj

[R7RS base] Returns true if and only if obj is a symbol.

(symbol? 'abc)     ⇒ #t
(symbol? 0)        ⇒ #f
(symbol? 'i)       ⇒ #t
(symbol? '-i)      ⇒ #f
(symbol? '|-i|)    ⇒ #t
Function: symbol-interned? symbol

Returns #t if symbol is an interned symbol, #f if it is an uninterned symbol. An error is signaled if symbol is not a symbol.

Function: symbol=? a b c …

[R7RS base] Every argument must be a symbol. Returns #t iff every pair of arguments are eq? to each other.

Function: symbol->string symbol

[R7RS base] Returns the name of symbol in a string. Returned string is immutable.

(symbol->string 'foo) ⇒ foo
Function: string->symbol string

[R7RS base] Returns a symbol whose name is a string string. String may contain weird characters.

(string->symbol "a") ⇒ a
(string->symbol "A") ⇒ A
(string->symbol "weird symbol name") ⇒ |weird symbol name|
Function: string->uninterned-symbol string

Like string->symbol, but the created symbol is uninterned.

(string->uninterned-symbol "a") ⇒ #:a
Function: gensym :optional prefix

Returns a fresh, uninterned symbol. The returned symbol can never be eq? to other symbol within the process. If prefix is given, which must be a string, it is used as a prefix of the name of the generated symbol. It is mainly for the convenience of debugging.

Function: symbol-sans-prefix symbol prefix

Both symbol and prefix must be symbols. If the name of prefix matches the beginning part of the name of symbol, this procedure returns a symbol whose name is the name of symbol without the matched prefix. Otherwise, it returns #f.

(symbol-sans-prefix 'foo:bar 'foo:) ⇒ bar
(symbol-sans-prefix 'foo:bar 'baz:) ⇒ #f
Function: symbol-append interned? objs …
Function: symbol-append objs …

Returns a symbol with the name which is a concatenation of string representation of objs.

If the first argument is a boolean, it is recognized as the first form; the first argument specifies whether the resulting symbol is interned or not.

Each other argument is converted to a string as follows: If it is a keyword, its name (with the preceding :) is used. For all other objects, x->string is used. (The special treatment of keyword is to keep the consistency before and after keyword-symbol integration. See Keyword and symbol integration, for the details.)

This is upper-compatible to Bigloo’s same name procedure, which only allows symbols as the arguments and the result is always interned.

(symbol-append 'ab 'cd) ⇒ abcd
(symbol-append 'ab ':c 30) ⇒ ab:c30
(symbol-append #f 'g 100) ⇒ #:g100

Next: , Previous: , Up: Core library   [Contents][Index]


For Gauche 0.9.14Search (procedure/syntax/module):