[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: All your local are belong to us
- From: Coda Highland <chighland@...>
- Date: Fri, 2 Oct 2015 12:45:57 -0700
On Fri, Oct 2, 2015 at 12:25 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2015-10-02 20:54 GMT+02:00 Parke <parke.nexus@gmail.com>:
>
>> Egor's original suggestion was that a warning be added to the REPL to
>> alert new users of the schism. A REPL warning in response to
>> singleton statements of the form "local namelist [‘=’ explist]" seems
>> like a good idea to me.
>
> The difficulty is that this is not a simple matter of changing
> a few lines in lua.c. One needs functionality equivalent to
> luac to diagnose the situation.
>
This isn't necessarily true. One COULD, for example, just see if the
beginning of the input line consists of 0+ whitespace characters,
followed by the string "local", followed by 1+ whitespace characters,
and emit the warning only in this case. (This would also catch "local
function".)
For a more involved but probably more robust solution, it would also
be possible to install a debug hook in each created chunk that would
determine if new locals were introduced (perhaps, for instance, by
checking lua_getlocal with an index of 1 and seeing if it returns
non-NULL) and then emit the warning. In this case, it may even be
possible to emit the names of the locals that would be lost, which
could be a further useful piece of information.
/s/ Adam