|
From: | John Yates |
Subject: | Re: Default lexical-binding to t |
Date: | Wed, 6 Nov 2024 15:23:24 -0500 |
If a "void variable" error is about to be thrown and the source defaulted to dynamic binding then
- Perform a dynamic lookup of the offending variable
- If the lookup is unsuccessful then issue the same error as always
- If the lookup is successful, then modify the diagnostic to mention the possibility of a dynamic / lexical binding clash
>>> 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
[Prev in Thread] | Current Thread | [Next in Thread] |