lua-users home
lua-l archive

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


On Fri, Oct 2, 2015 at 9:30 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> 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
>> parenthesis...
>
> 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
this schism.

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.

-Parke