GNU bug report logs -
#46387
28.0.50; Compiled code making a variable dynamic stopped working
Previous Next
Full log
View this message in rfc822 format
9 feb. 2021 kl. 16.31 skrev Stefan Monnier <monnier <at> 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.
This bug report was last modified 4 years and 100 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.