lua-users home
lua-l archive

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


Patrick Donnelly wrote:

4: attempt to call a nil value

If you append a semicolon to the end of line 3 however
(forcing the end of the statement?), the error is fixed.

I'm guessing this is a bug because, as I understand it,
semicolons are optional and only intended as syntactic
sugar.

See <http://www.lua.org/manual/5.1/manual.html#2.5.8>:

As an exception to the free-format syntax of Lua, you
cannot put a line break before the '(' in a function call.
This restriction avoids some ambiguities in the language.
If you write

    a = f
    (g).x(a)

Lua would see that as a single statement, a = f(g).x(a).
So, if you want two statements, you must add a semi-colon
between them. If you actually want to call f, you must
remove the line break before (g).

As Shmuel pointed out, though, this should be a compile-time
error ("ambiguous syntax").

--
Aaron
http://arundelo.com/

_________________________________________________________________
Who's that on the Red Carpet? Play & win glamorous prizes. http://club.live.com/red_carpet_reveal.aspx?icid=REDCARPET_hotmailtextlink3