[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: All your local are belong to us
- From: Parke <parke.nexus@...>
- Date: Fri, 2 Oct 2015 11:54:02 -0700
On Fri, Oct 2, 2015 at 9:30 AM, Roberto Ierusalimschy
>> much better would be if the REPL had some way to enter a whole bunch
>> of code in a single operation. maybe some kind of quoting or
> Something like do-end?
do-end allows experienced Lua users to use locals across multiple
lines in the REPL.
do-end does nothing to help new Lua users discover that local does not
work "as expected" in the REPL.
Additionally, do-end is not interactive. I can never interactively
use any of the locals created in a do-end block. All such locals
disappear immediately after the end.
Right now, Lua is two separate languages. In Lua-A, top level locals
persist. In Lua-B, locals do not persist. Lua-A is the language you
get when you put multiple statements into a file and run the file with
the "lua" comamnd. Lua-B is the language you get when you enter the
REPL via the very same "lua" command.
It is not surprising to me that new users are repeatedly confused by
Most of the code new users will see is Lua-A. But new users are
highly likely to try to test their understanding as they learn by
jumping into the REPL. Where, without warning, they will be using
Lua-B instead! I imagine this can be highly frustrating and time
consuming for new users, and may well leave them with an unnecessary
bad impression of the language.
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.