gensym: Build a temporary symbol

Description Usage Arguments Details Value See Also

Description

gensym is an analogue of Common Lisp's gensym, for use in writing macros. It builds randomly generated symbols which can be made to avoid shadowing bindings already defined in an environment.

Usage

1
gensym(str = "G", lst = NULL, len = 10)

Arguments

str

A string to prepend to the generated symbol name.

lst

A list or vector of symbols or strings. These values are guaranteed not to be returned as the generated symbol.

len

How long (in characters) the symbol should be.

Details

gensym provides some additional control over the form of the symbol it generates: the user can specify how long the symbol should be (though asking for length-1 unique symbols is unlikely to be useful), specify a list of symbols which should be discarded in favor of a new candidate if they are generated, and ask for a particular string to be prepended for ease of processing or as even more insurance against name conflicts.

Value

The generated symbol.

See Also

The main use of this function is providing temporary symbols that macro definitions can use to avoid capturing variables from the calling environment; see macro and link{defmacro} for the macro facility in question.


wwbrannon/schemeR documentation built on May 4, 2019, 12:03 p.m.