From: "Davis Herring" <herring@lanl.gov>
To: "MON KEY" <monkey@sandpframing.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: `setplist' on local var escaping let binding
Date: Thu, 21 Oct 2010 05:46:06 -0700 (PDT) [thread overview]
Message-ID: <49359.130.55.132.18.1287665166.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <AANLkTinkfo5ZUWZkhh3KT7ibTDA-TeWUAxWmxOSz34dP@mail.gmail.com>
> (progn
> (unintern "ms" obarray)
> (let (ms)
> (setplist 'ms '(can-has a-plist))
> `(,(get 'ms 'can-has)
> ,(intern-soft "ms" obarray))))
> (a-plist nil)
Symbols are created (or retrieved) when a form is read, so the rest of
this form is still using the old ms. Your life will be much simpler if
you forget that `unintern' exists at all. If you want to have a dynamic
mapping where it's important to remove elements, just use a hash table.
> (let ((ms (make-symbol "bubba")))
> (apply #'setplist
> (list (eval (list 'quote (identity ms)))
> '(not a symbol really?)))
> `(:non-thing-bubba ,(not (intern-soft "bubba" obarray))
> :but-with-a-plist ,(apply #'get
> (list (eval (list 'quote (identity ms)))
> 'symbol))
> :is-thing-like-ms ,(eq (intern-soft "ms" obarray)
> (intern-soft "ms" obarray))))
You continue to use `identity' for no reason, and seem to have discovered
an even more verbose synonym for nothing: (eval (list 'quote foo)) is
exactly equivalent to foo. (apply #'foo (list bar baz)) is also just the
same as (foo bar baz), and `obarray' is the default argument to the
interning functions. All :symbols evaluate to themselves, so you can
finally write (with about half the characters)
(let ((ms (make-symbol "bubba")))
(setplist ms '(not a symbol really?))
(list :non-thing-bubba (not (intern-soft "bubba"))
:but-with-a-plist (get ms 'symbol)
:is-thing-like-ms (eq (intern-soft "ms") (intern-soft "ms"))))
at which point the only remaining quarrels are your use of "thing" and
"non-thing" (but surely that's just the result of the confusion, not the
cause) and your apparent suspicion that `intern-soft''s value will change
between two adjacent calls.
It's really not that confusing if you don't make it so!
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
next prev parent reply other threads:[~2010-10-21 12:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-20 23:28 `setplist' on local var escaping let binding MON KEY
2010-10-21 1:10 ` Stefan Monnier
2010-10-21 3:02 ` MON KEY
2010-10-21 4:26 ` Stephen J. Turnbull
2010-10-21 9:06 ` Andreas Schwab
2010-10-21 12:46 ` Davis Herring [this message]
2010-10-21 13:35 ` Thien-Thi Nguyen
2010-10-21 18:38 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49359.130.55.132.18.1287665166.squirrel@webmail.lanl.gov \
--to=herring@lanl.gov \
--cc=emacs-devel@gnu.org \
--cc=monkey@sandpframing.com \
--cc=monnier@iro.umontreal.ca \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.