lua-users home
lua-l archive

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

On 15 September 2010 11:35, David Kastrup <> wrote:
> Huh?  What makes you think that?  Aren't you confusing "\n" with ";"?

If you try it you can test that they behave differently.

On 15 September 2010 12:08, Fabien <> wrote:
> The former is three nested calls; the latter is two calls of depth 1.

I think that the former is actually three subsequent calls. The call
stack should always be of depth 1. Am I wrong?

And in non interactive mode the second syntax gives an error to warn
users that the syntax is ambiguous. I believe this is the sanest way
to address the problem.

In interactive mode, short of delaying all function calls, the
previous input is already consumed. You can recover the correct
behaviour by putting everything in a do ... end block:

Lua 5.1.4  Copyright (C) 1994-2008, PUC-Rio
> function f(x) print('f', x) return f end
> do
>> f(1)(f)(3)
>> end
f       1
f       function: 0x12963a0
f       3
> do
>> f(1)
>> (f)(3)
stdin:3: ambiguous syntax (function call x new statement) near '('