Gérard
Gérard

Reputation: 17

Symbols generated by gensym

     (let ((a 34)) (print a))
    34
    34

that is what is expected

but

    (let ((#:a 34)) (print #:a))

    The variable #:A is defined but never used. 
    compilation unit finished
    ;   Undefined variable:
    ;     #:A

However uninterned symbol seems to work fine in macros with gensym ?

Upvotes: 0

Views: 195

Answers (1)

Sylwester
Sylwester

Reputation: 48745

In macros you generate a symbol and you use the very same symbol by evaluating the binding you made. It would be the same as:

(let ((sym '#:a))
  (eq sym sym))    ; ==> T

You do something different in your example:

(eq '#:a '#:a)     ; ==> NIL

In the first you have an uninterned symbol but it is the same used every time since the same value is used, in the second (and in your code) you have several similar looking uninterned symbols that are in reality different.

Upvotes: 1

Related Questions