unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
Subject: Re: Defadvice use
Date: Tue, 19 Apr 2005 01:07:49 -0400	[thread overview]
Message-ID: <barmar-724417.01074919042005@comcast.dca.giganews.com> (raw)
In-Reply-To: 1113869741.838603.250620@o13g2000cwo.googlegroups.com

In article <1113869741.838603.250620@o13g2000cwo.googlegroups.com>,
 "rgb" <rbielaws@i1.net> wrote:

> Stefan Monnier wrote:
> > > Doesn't (let (bookmark-bmenu-other-window) ...) have limited life.
> >
> >   (let (bookmark-bmenu-other-window) ...)
> >
> > only affects the bookmark-bmenu-other-window *variable*, not the
> > bookmark-bmenu-other-window function.
> >
> 
> If that isn't a bug waiting to happen I don't know what is.
> You appear to be asserting that it's documented to work that
> way but I'd counter with 2 arguments.
> 
> 1.  The `feature' is only _implied_, not documented.  There is
>     no mention in any Elisp manual section that covers plists
>     or symbol function cells about this behavior.

The Elisp manual specifically says that 'let' binds variables.  That's 
all it does.  Does it have to explicitly say all the things it *doesn't* 
do, like binding functions and property lists?  Function and variable 
bindings of symbols are totally independent.

If you want to bind a function, you can (require 'cl) and then use 
'flet'.

> 
> 2.  The `feature' invalidates much of the documented behavior of
>     symbols unless you know how the symbol was created.
> 
> Look at this:
> 
> (defun test1 ()
>   (let (a01)
>     (put 'a01 'hold "this")
>     (symbol-plist 'a01)))
> 
> (put 'a01 'hold "that") ; insure symbol already exists
> (symbol-plist 'a01)
>  => (hold "that")       ; value is there as expected
> 
> (test1)
>  => (hold "this")
> 
> (symbol-plist 'a01)
>  => (hold "this")       ; external value unexpectedly changed
> 
> (unintern "a01")        ; insure it doesn't exist
> (symbol-plist 'a01)
>  => nil                 ; no error.
> 
> (test1)
>  => (hold "this")
> 
> (symbol-plist 'a01)    ; Given the external value should change
>  => nil                ; it now unexpectedly doesn't

You're looking at the plist of a different symbol.  test1 is still 
referencing the symbol that you uninterned.  When you then type 'a01 
later, you intern a new symbol, which is not the one whose plist is 
modified when you call test1.

> It's obviously impossible to easily create any function or
> macro that manipulates function or property cells unless you
> can guarantee none of the symbols are ever created by let.
> 
> Since it appears to be by design, I'd be terribly curious to
> see any archive of discussions concerning why this is
> appropriate behavior.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

  parent reply	other threads:[~2005-04-19  5:07 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-18 12:56 Defadvice use Matthias
2005-04-18 17:11 ` rgb
2005-04-18 17:25   ` Johan Bockgård
2005-04-18 19:05     ` rgb
2005-04-18 19:43       ` Stefan Monnier
2005-04-19  0:15         ` rgb
2005-04-19  0:28           ` Stefan Monnier
2005-04-19  3:48             ` Mis-features of let (was Defadvice use) rgb
2005-04-19  4:31               ` Mis-features of let Stefan Monnier
2005-04-19  6:38                 ` rgb
2005-04-19 12:21                   ` Stefan Monnier
2005-04-19 20:31                     ` rgb
2005-04-19 21:45                       ` David Kastrup
2005-04-19 12:55                   ` Barry Margolin
2005-04-19 20:31                     ` rgb
2005-04-20  4:12                       ` Barry Margolin
2005-04-19 21:10                     ` rgb
2005-04-19 21:57                       ` Kevin Rodgers
2005-04-19 22:00                       ` David Kastrup
2005-04-20  1:04                         ` rgb
2005-04-20 10:04                           ` David Kastrup
2005-04-20 11:57                             ` Stefan Monnier
2005-04-20 14:41                           ` Thien-Thi Nguyen
2005-04-19  9:41               ` Thien-Thi Nguyen
2005-04-19  5:07           ` Barry Margolin [this message]
2005-04-18 17:52 ` Defadvice use Stefan Monnier
2005-04-18 21:07   ` Matthias
2005-04-18 23:20     ` Stefan Monnier
2005-04-18 20:28 ` Kevin Rodgers

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=barmar-724417.01074919042005@comcast.dca.giganews.com \
    --to=barmar@alum.mit.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).