emacs-devel
[Top][All Lists]
Advanced

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

Re: Default lexical-binding to t


From: John Yates
Subject: Re: Default lexical-binding to t
Date: Wed, 6 Nov 2024 15:23:24 -0500

Being fundamentally a programmer in languages that support only lexical binding, I have little sense of the mechanics underlying dynamic binding.  That said, I wonder if something along these line could help a bit:

If a "void variable" error is about to be thrown and the source defaulted to dynamic binding then
/john

On Wed, Nov 6, 2024 at 2:27 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> What bothers me is how do I know whether a given Lisp file of mine
>>> will have problems under lexical-binding.  Do we have any tools which
>>> will help me determine that?
>> It's generally impossible to do that reliably (it can be reduced to
>> a variant of the halting problem), but the problem is exactly the same
>> as that of converting from dynbind to lexbind (which we do describe in
>> the manual).
> How about a less-reliable tool that catches some easy-to-detect problems?
> For example, look in every defun and see if the macro-expanded form of the
> function body refers to a variable that is neither 1) declared with 'defvar'
> or 2) let-bound in that function. This logic might not be exactly what we
> want since I haven't thought very long about it, but something along these
> lines could hopefully catch many errors.

That's what the compiler's warnings give you (plus a few related cases
such as the vars that are let-bound but not used within that let's
lexical scope).


        Stefan




--
John Yates
505 Tremont St, #803
Boston, MA 02116

reply via email to

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