[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't M-x compile-defun `edebug' because dynamic variables are false

From: Alan Mackenzie
Subject: Re: Can't M-x compile-defun `edebug' because dynamic variables are falsely taken as lexical.
Date: Wed, 4 Jan 2017 20:04:58 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

Hello, Stefan

On Wed, Jan 04, 2017 at 10:23:16AM -0500, Stefan Monnier wrote:
> > Ouch!  There seems to be a clash between symbols (which are global,
> > dynamic) and lexical variables (which are local and "invisible"): the
> > only way to mark a variable as lexical is at the global level.

> Yes, there are some subtleties there.  The main issue is that every
> occurrence of an identifier, whether a binding occurrence or a "use" can
> be lexical or dynamic, but we don't want the coders to have to
> constantly specify which uses and which bindings are lexical and which
> are dynamic.  So we offer ways to "mark" symbols are "this one uses
> dynamic scoping".  There are 2 such ways:
> - *Evaluation* of (defvar VAR VAL . REST) marks this variable as being
>   dynamically scoped in all the code that will be compiled in this session.
> - *Compilation* of (defvar VAR . REST) marks this variable as being
>   dynamically scoped in the current compilation unit.

> > (vi) e (special-variable-p 'edebug-breakpoints).

> > This last returns nil.  This suggests edebug-breakpoints has been bound
> > as a lexical variable, rather than a dynamic one.  (There is a defvar
> > for it earlier in the file.)  This is surely not right.

> special-variable-p only indicates if (defvar VAR VAL . REST) was evaluated.

So it would seem.  There is a bug in the elisp manual, which says that a
variable being declared by defvar will cause special-variable-p to
return t for it.   The doc string looks right, though far from helpful
for anybody who doesn't already know variable binding inside out, and
even a bit cryptic for those who do.

special-variable-p would appear to be a near useless function, since it
doesn't do what it's name says.

"Defining Variables" in the elisp manual states that "(defvar foo)" makes
foo a special variable; yet "(special-variable-p 'foo)" returns nil.  This
has got to be a bug, of some sort.

There appears to be no way of checking whether a variable's binding is
(or will be) lexical.

I can foresee quite a bit of confusion happening over all this, if it
hasn't happened already.

Am I missing something, or is this all really as incoherent as it
appears to me?

>         Stefan

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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