《通链参考手册》


Function GENSYM

●语法设定:

gensym &optional x => new-symbol

●参数和值:

x---a string or a non-negative integer. Complicated defaulting behavior; see below.

new-symbol---a fresh, uninterned symbol.

●详情:

Creates and returns a fresh, uninterned symbol, as if by calling make-symbol. (The only difference between gensym and make-symbol is in how the new-symbol's name is determined.)

The name of the new-symbol is the concatenation of a prefix, which defaults to "G", and a suffix, which is the decimal representation of a number that defaults to the value of *gensym-counter*.

If x is supplied, and is a string, then that string is used as a prefix instead of "G" for this call to gensym only.

If x is supplied, and is an integer, then that integer, instead of the value of *gensym-counter*, is used as the suffix for this call to gensym only.

If and only if no explicit suffix is supplied, *gensym-counter* is incremented after it is used.

●例子:

 (setq sym1 (gensym)) =>  #:G3142
 (symbol-package sym1) =>  NIL
 (setq sym2 (gensym 100)) =>  #:G100
 (setq sym3 (gensym 100)) =>  #:G100
 (eq sym2 sym3) =>  false
 (find-symbol "G100") =>  NIL, NIL
 (gensym "T") =>  #:T3143
 (gensym) =>  #:G3144

●副作用:

Might increment *gensym-counter*.

●受制于:

*gensym-counter*

●例外情况:

Should signal an error of type type-error if x is not a string or a non-negative integer.

●更多信息:

gentemp, *gensym-counter*

●说明:

The ability to pass a numeric argument to gensym has been deprecated; explicitly binding *gensym-counter* is now stylistically preferred. (The somewhat baroque conventions for the optional argument are historical in nature, and supported primarily for compatibility with older dialects of Lisp. In modern code, it is recommended that the only kind of argument used be a string prefix. In general, though, to obtain more flexible control of the new-symbol's name, consider using make-symbol instead.)


X3J13设计清单非标准部分,可查下面章节:


◇首页 § ◎章节目录 § □内容索引 § ○符号索引 § △术语表 § ※设计草案