next up previous

12.7.1 Gensym

The gensym function returns a special, sequenced symbol that can be stored as a single field. This is primarily for tagging patterns that need a unique identifier, but the user does not care what the identifier is. Multiple calls to gensym are guaranteed to return different identifiers of the form

genX

where X is a positive integer. The first call to gensym returns gen1; all subsequent calls increment the number. Note that gensym is not reset after a call to clear. If users plan to use the gensym feature, they should avoid creating facts which include a user-defined field of this form.

Example

(assert (new-id (gensym) flag1 7))

which, on the first call, generates a fact of the form

(new-id gen1 flag1 7)


next up previous