emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible defvar bug


From: Thierry Volpiatto
Subject: Re: Possible defvar bug
Date: Mon, 18 Feb 2013 16:41:12 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.93 (gnu/linux)

Alan Mackenzie <address@hidden> writes:

> On Mon, Feb 18, 2013 at 04:00:28PM +0100, Didier Verna wrote:
>> Jambunathan K <address@hidden> wrote:
>
>> > I am certain I don't understand what these paragraphs mean,
>> > particularly the second one.
>> > lands.
>
>> > ,----  C-h f
>> > | If SYMBOL has a local binding, then this form affects the local
>> > | binding.  This is usually not what you want.  Thus, if you need to
>> > | load a file defining variables, with this form or with `defconst' or
>> > | `defcustom', you should always load that file _outside_ any bindings
>> > | for these variables.  (`defconst' and `defcustom' behave similarly in
>> > | this respect.)
>> > `----
>
>>   This means that:
>
>> ELISP> (let ((foo 3))
>>       (defvar foo 1)
>>       (print foo))
>> 3
>> ELISP> foo
>> *** Eval error ***  Symbol's value as variable is void: foo
>> ELISP> 
>
>
>> And, no, this is almost never what you want :-) Just like Tassilo
>> noticed by accident.
>
> Why would anybody want to defvar a variable inside a let binding which
> also defines it, anyway?  It may not be totally invalid, but it's
> certainly in breach of good taste.  I would argue that the current
> behaviour _is_ what is wanted, since it alerts one to a probable error.

See also documentation of `require' which should not be used inside
`let' bindings for same reasons.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]