lua-users home
lua-l archive

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

On 12/18/2015 07:19 AM, Rena wrote:
The exception is when it's ambiguous:
x = f
(a or b):c()
That expression could be interpreted as two statements or one (remove the
line break and see). In that case Lua is kind enough to make an exception
to the "ignore whitespace" rule and raise an error

That's not nice, that's nasty -- whitespace should be ignored except to separate tokens. The statement is equally "ambiguous" regardless of the newline, and it isn't ambiguous at all so long as the semantics are documented. Let the programmer format his code as he likes.

And, thank goodness Lua does *NOT* raise that error anymore since 5.2 (which it raised on statements even simpler than the example you gave). You can resolve the ambiguity yourself by using semicolons and/or parenthesis, but the former behavior forced disagreeable (to me) formatting. Furthermore, if you always terminate your statements with semicolons, it doesn't appear ambiguous at all.

-- David