From: Joe Corneli <jcorneli@math.utexas.edu>
Subject: Re: comparing symbols coming from gensym?
Date: Wed, 24 Aug 2005 10:57:58 -0500 [thread overview]
Message-ID: <E1E7xdW-00040E-00@lab1.ma.utexas.edu> (raw)
In-Reply-To: <ksahed.46.ln@acm.acm> (message from Alan Mackenzie on Wed, 24 Aug 2005 08:24:52 +0000)
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.
Incidentally,
(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
similar?
(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'
docstring?
next prev parent reply other threads:[~2005-08-24 15:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.4802.1124860720.20277.help-gnu-emacs@gnu.org>
2005-08-24 8:24 ` comparing symbols coming from gensym? Alan Mackenzie
2005-08-24 15:57 ` Joe Corneli [this message]
2005-08-24 9:00 ` N. Raghavendra
2005-08-24 4:50 Joe Corneli
2005-08-24 15:48 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1E7xdW-00040E-00@lab1.ma.utexas.edu \
--to=jcorneli@math.utexas.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).