emacs-devel
[Top][All Lists]
Advanced

[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 17:42:41 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

>> 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)))

This problematic situation is problematic regardless of the presence of
makunbound.  You simply can't have a (defvar <foo> <val>) for a variable
you need to use lexically elsewhere.

> 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?

Note that the current implementation technique for "bound/unbound" still
works just fine with multithreading (the implementation of dynamically
scoped "let" is more problematic but it has no particular problematic
interaction with makunbound).

So, adding multi-threading won't make much difference to this "problem".


        Stefan



reply via email to

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