[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The purpose of makunbound
From: |
Kelly Dean |
Subject: |
Re: The purpose of makunbound |
Date: |
Wed, 18 Feb 2015 18:53:31 +0000 |
Stefan Monnier wrote:
> Why would that be an error?
Because of a classic mistake with dynamic binding:
(defvar bar nil)
(defun foo ()
(if something-rare...
(makunbound 'bar)) ; Intent is global
(do-something))
(let ((bar (something))) ; Intent is lexical
(do-some-stuff)
(foo)
(if bar ; Oops
(some-other-stuff)))
Well the classic is with «set», not makunbound, but the problem is the same.
There are legitimate cases for using «set» in dynamic «let», so the interpreter
must allow it, and you just have to deal with the possibility of that kind of
mistake. But for makunbound, if there are no legitimate use cases, then the
interpreter could catch it.
> How often have you bumped into that error?
Never.
> 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
[snip]
> You talk about "global variable" vs "dynamic variable", but that
> difference is only in your head because of the interpretation you chose.
For single-threaded code, there's no difference, but for multi-threaded, there
is, which you already mentioned. Why have inconsistent interpretations for
single vs. multi, when you can have a consistent one for both?
And aren't you planning to add multi-threading to Emacs?
- [PATCH] (Updated) Run hook when variable is set, (continued)
- [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, 2015/02/18
- Re: The purpose of makunbound,
Kelly Dean <=
- 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
- Re: The purpose of makunbound, Stephen J. Turnbull, 2015/02/19