lua-users home
lua-l archive

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


Ricardo Ramos Massaro <ricardo.massaro@gmail.com> writes:

> On Wed, Sep 15, 2010 at 8:41 AM, David Kastrup <dak@gnu.org> wrote:
>> While this more or less tells us that Lua is indeed a mess, it does not
>> tell us what the above input will give.  "Lua would see that" does not
>> suggest that Lua would actually throw an error.  Indeed, "Lua would see
>> that" suggests that _if_ you want to have Lua see that as a single
>> statement, writing it like that should work, on contradiction to the
>> last sentence of the quote (which turns out more correct).
>
> I'm not sure I understand what you're saying, but there's no reason to
> throw an error at all, and I don't see the manual as
> self-contradicting (maybe a little confusing).
>
> The whole point the manual is trying to make is that both
>
>   a = f(g).x(a)    -- [A] meaning "a = (f(g).x(a))"
>   a = f; (g).x(a)  -- [B]
>
> are valid (different) expressions, and without the "no line break
> before `(' for function call" rule, the following two lines:
>
>   a = f
>   (g).x(a)
>
> would be *apparently* [B] (to a human user), but would actually be
> "seen" by Lua as [A] (because line breaks are usually ignored by the
> parser).

It would have taken you 10% of the time for writing the above
speculation to actually try it out.

lua /tmp/junk.lua
lua: /tmp/junk.lua:2: ambiguous syntax (function call x new statement) near '('

Lua refuses to see those two lines either way and throws a syntax error
instead.

-- 
David Kastrup