[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46387: 28.0.50; Compiled code making a variable dynamic stopped work
From: |
Mattias Engdegård |
Subject: |
bug#46387: 28.0.50; Compiled code making a variable dynamic stopped working |
Date: |
Tue, 9 Feb 2021 17:49:20 +0100 |
9 feb. 2021 kl. 16.31 skrev Stefan Monnier <monnier@iro.umontreal.ca>:
> Adding a variable to the context creates a new scope.
> A `progn` should not introduce a new scope.
All right, `defvar` modifies the current scope and only let, let* and lambda
create new scopes. Fine, but it leaves questions unanswered.
* Does `defvar` affect new bindings only, or variable references in the current
scope as well? In
(let ((my-var EXPR))
(defvar my-var)
(use my-var))
does the last line refer to the lexical my-var bound in the first line, or to
the dynamic my-var?
* Does the defvar have to be 'executed' to be effective? That's how the
interpreter works, but it clearly can't work in the compiler. The defvar form
probably has to 'precede' the binding form which it tries to affect, in some
way.
> The (with-suppressed-warnings (...) (defvar)) form is used at
> several places. It's the preferred way to declare a variable
> dynamically scoped without incurring the "not prefixed" warning and
> without making the `with-suppressed-warnings` silencer cover more code
> than intended.
Yes, but it does (currently) work if used on a single variable at a time, which
is the suggested workaround for the time being.