[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.5 シンボル

Builtin Class: <symbol>

シンボルを表すクラスです。

Reader Syntax: |name|

R5RSのシンボルの定義では許されていない文字を使った妙な名前のシンボルを表記するのに 使う構文です。インタプリタが大文字小文字を区別しないモードで走っている場合は、 大文字を含むシンボルを表記するときにも使えます (大文字小文字の区別参照)。

この表記はCommonLispから取られました。いくつかのSchemeでも同様の表記を採用しています。

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

When an S-expression including uninterned symbols are printed, the srfi-38 syntax is used to indicate which uninterened symbol is the same (eq?) to which.

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

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

[R5RS] objがシンボルなら#tを返します。

 
(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 signalled if symbol is not a symbol.

Function: symbol->string symbol

[R5RS] symbolの名前を文字列で返します。返される文字列は変更不可です。

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

[R5RS] 文字列stringを名前に持つシンボルを返します。

 
(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 mached prefix. Otherwise, it returns #f.

 
(symbol-sans-prefix 'foo:bar 'foo:) ⇒ bar
(symbol-sans-prefix 'foo:bar 'baz:) ⇒ #f

[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Shiro Kawai on November, 22 2009 using texi2html 1.78.