[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: comparing symbols coming from gensym?

From: Joe Corneli
Subject: Re: comparing symbols coming from gensym?
Date: Wed, 24 Aug 2005 10:57:58 -0500

   When you do (equal a 'G2007), this _creates_ a full-bloodied
   industrial-strength NEW _interned_ symbol G2007, since there wasn't
   already such a symbol in the obarray.  This is distinct from your
   gensymmed one.

   That is, in fact, the whole point of gensym - to create a symbol distinct
   from any other symbol which ever has been or ever will be.  You asked for
   it, you got it!  If you want to actually _use_ it, you'll need something
   like (symbol-value a)

(setq a (gensym)) ;=> G2016 this morning
(symbol-name a)   ;=> "G2016"
(symbol-value a)  ;=> `void-variable' error

So I guess `symbol-name' is the thing to use.


(symbol-value 'G2016)

also gives a `void-variable' error.

The moral of the story here is that I shouldn't be using `gensym' but
rather something "gensym-like", better tailored to the situation I'm
working in.

Just to pick up the original thread briefly, the fact that I was using
`equal' and not `eq' is maybe an argument for the comparison to return
`t' even though the two variables are distinct and stored in
different places; remember, it says

| Return t if two Lisp objects have similar structure and contents.
| They must have the same data type.

They have no contents (as evidenced above) and appear to be internally

(type-of 'G2016)
(type-of a)

Both are symbols.  I guess the interpreter judges them by their
situation in the world as well as their internal contents, which
doesn't seem very egalitarian of it.

Or perhaps the idea is like with infinities, even though both values
are singular, they aren't necessarily equal?

Perhaps some additional information should appear on the `equal'

reply via email to

[Prev in Thread] Current Thread [Next in Thread]