[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The purpose of makunbound
From: |
Stefan Monnier |
Subject: |
Re: The purpose of makunbound |
Date: |
Wed, 18 Feb 2015 09:34:16 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
>>> What's the use case of doing makunbound on a dynamically let-bound variable?
>> What's the use case for disallowing it?
> Catching errors. If some code F does makunbound on a symbol that it assumes
> is currently used as the global variable, but F is called from some other
> code that dynamically let-binds the symbol, then F will accidentally set the
> dynamic variable to the special unboundedness value rather than unbind the
> global variable.
Why would that be an error? How often have you bumped into that error?
> If that's a bogus thing to do, then by disallowing it, the interpreter could
> catch the error.
I don't know if that would be bogus or not, because I don't know why
makunbound was called in your example.
And remember: a (dynamically scoped) `let' does not necessarily mean to
make a local binding, it can also be understood to mean to temporarily
change the global variable (i.e. it's just a shorthand for
(let ((old <var>))
(unwind-protect
(progn (setq <var> <val>)
,@body)
(setq <var> old)))
with the advantage that it doesn't burp in the first line of <var> is
unbound and it properly sets it back to unbound in the end in that
case).
You talk about "global variable" vs "dynamic variable", but that
difference is only in your head because of the interpretation you chose.
Stefan
- Re: [PATCH] (Updated) Run hook when variable is set, (continued)
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/12
- [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/13
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/13
- Re: [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/14
- Re: [PATCH] (Updated) Run hook when variable is set, Stefan Monnier, 2015/02/15
- [PATCH] (Updated) Run hook when variable is set, Kelly Dean, 2015/02/16
- Re: [PATCH] (Updated) Run hook when variable is set, Richard Stallman, 2015/02/17
- The purpose of makunbound (Was: Run hook when variable is set), Kelly Dean, 2015/02/17
- Re: The purpose of makunbound, Stefan Monnier, 2015/02/18
- Re: The purpose of makunbound, Kelly Dean, 2015/02/18
- Re: The purpose of makunbound,
Stefan Monnier <=
- Re: The purpose of makunbound, Kelly Dean, 2015/02/18
- Re: The purpose of makunbound, Stefan Monnier, 2015/02/18
- Re: The purpose of makunbound, Kelly Dean, 2015/02/19
- Re: The purpose of makunbound, Kelly Dean, 2015/02/21
- Re: The purpose of makunbound, Kelly Dean, 2015/02/19
- Re: The purpose of makunbound, Stefan Monnier, 2015/02/19
- Re: The purpose of makunbound, Kelly Dean, 2015/02/19
- Re: The purpose of makunbound, Stefan Monnier, 2015/02/19
- Re: The purpose of makunbound, Kelly Dean, 2015/02/20
- Re: The purpose of makunbound, Stefan Monnier, 2015/02/20