lua-users home
lua-l archive

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

> >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").

Ah well, I got the ambiguous syntax error in an interpretter, and then tried to show it to some friends in IRC with a luabot. I forgot that I wasn't using line breaks in IRC >:)

Why is it not automatically assumed that f is not being called if a line break appears after f but before the opening parenthesis? I would think a compile warning would be better than an actual error.

-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say."

-Will Durant