lua-users home
lua-l archive

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


On Sat, Jul 24, 2010 at 3:20 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> I'm wondering why this is necessary.  Most other languages with a REPL
>> do not require the user to disambiguate expressions and statements.
>
> It is not necessary. The Lua stock interpreter could try first
>        return <user input>
> and then, if that fails, try
>        <user input>
>
> This is almost what it does already, except that it only tries "return ..."
> if the line starts with '='.
>
> The problem with the automatic approach is that you'd get more noise.
> For instance,
>        io.write("Hello")
> would output
>        Hellotrue
> as you can see by entering
>        =io.write("Hello")
>

What if you did something like this?

> io.write("Hello\n")
Hello
=> true
>

That's how Ruby's IRB utility works. Granted, if you remove the \n,
you would get "Hello=> true", but that's a problem in IRB too.

-- 
~Jonathan