Joe Corneli <[EMAIL PROTECTED]> wrote on Tue, 23 Aug 2005 23:50:46
-0500:

> Why is it that

> (setq a (gensym)) ;=> G2007
> a                 ;=> G2007
> (equal a 'G2007)  ;=> nil

> while 

> (setq a 'foo)    ;=> foo
> a                ;=> foo
> (equal a 'foo)   ;=> t

> ?

This is because your gensymmed symbol, 'G2007, has only been
"half-created".  It hasn't been "interned" in the "obarray", the
structure which holds (almost) all symbols - that 'G2007 is a
free-floating symbol.

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)

Look up `gensym' in the CL manual, and `intern' in the Elisp manual.

-- 
Alan Mackenzie (Munich, Germany)

Email: [EMAIL PROTECTED]; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

Reply via email to