From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Davis Herring" Newsgroups: gmane.emacs.devel Subject: Re: `setplist' on local var escaping let binding Date: Thu, 21 Oct 2010 05:46:06 -0700 (PDT) Message-ID: <49359.130.55.132.18.1287665166.squirrel@webmail.lanl.gov> References: Reply-To: herring@lanl.gov NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1287666464 10481 80.91.229.12 (21 Oct 2010 13:07:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 21 Oct 2010 13:07:44 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: "MON KEY" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 21 15:07:43 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P8uru-0004mU-KB for ged-emacs-devel@m.gmane.org; Thu, 21 Oct 2010 15:07:42 +0200 Original-Received: from localhost ([127.0.0.1]:49498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8urt-0004m5-Lo for ged-emacs-devel@m.gmane.org; Thu, 21 Oct 2010 09:07:41 -0400 Original-Received: from [140.186.70.92] (port=35344 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8uXN-0006sx-HU for emacs-devel@gnu.org; Thu, 21 Oct 2010 08:46:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8uX3-0001E3-Tc for emacs-devel@gnu.org; Thu, 21 Oct 2010 08:46:28 -0400 Original-Received: from proofpoint2.lanl.gov ([204.121.3.26]:47815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8uX3-0001Co-Kp for emacs-devel@gnu.org; Thu, 21 Oct 2010 08:46:09 -0400 Original-Received: from mailrelay1.lanl.gov (mailrelay1.lanl.gov [128.165.4.101]) by proofpoint2.lanl.gov (8.14.3/8.14.3) with ESMTP id o9LDbeKI029158; Thu, 21 Oct 2010 07:37:40 -0600 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by mailrelay1.lanl.gov (Postfix) with ESMTP id DE191150511; Thu, 21 Oct 2010 06:46:06 -0600 (MDT) X-NIE-2-Virus-Scanner: amavisd-new at mailrelay1.lanl.gov Original-Received: from webmail1.lanl.gov (webmail1.lanl.gov [128.165.4.106]) by mailrelay1.lanl.gov (Postfix) with ESMTP id CAAB515041A; Thu, 21 Oct 2010 06:46:06 -0600 (MDT) Original-Received: by webmail1.lanl.gov (Postfix, from userid 48) id C55F21CA81B3; Thu, 21 Oct 2010 06:46:06 -0600 (MDT) Original-Received: from 130.55.132.18 (SquirrelMail authenticated user 196434) by webmail.lanl.gov with HTTP; Thu, 21 Oct 2010 05:46:06 -0700 (PDT) In-Reply-To: User-Agent: SquirrelMail/1.4.8-5.el5_4.10.lanl3 X-Priority: 3 (Normal) Importance: Normal X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.2.15, 1.0.148, 0.0.0000 definitions=2010-10-21_05:2010-10-21, 2010-10-21, 1970-01-01 signatures=0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:131934 Archived-At: > (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.