lua-users home
lua-l archive

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


Of course a simple way to remove this ambiguity would be to require ';' between statements or to terminate statements. Of course this would require people to make large increases in the size of their files but it might be worth it to remove the ambiguity.

Luerl parses them as one call, strictly left-to-right until there is nothing more which can be added to the call.

Robert


From: "Sven Olsen" <sven2718@gmail.com>
To: "Lua mailing list" <lua-l@lists.lua.org>
Sent: Thursday, 13 December, 2012 3:54:21 PM
Subject: Ambiguous syntax


There are several valid situations where you may want a newline between the function and the parameters.

Certainly, but 5.1's ambiguous syntax check rarely got in the way of this.  It was safe to write:

    object.member_function(
        some, collection, of, parameters)

The case that triggered a false positive was:

    object.member_function
        (some, collection, of, parameters)

I haven't often seen the second pattern used in the wild -- though for programmers who prefer it, I'm sure 5.1's ambiguous syntax error would have been an annoyance.

The need to scatter semicolons through otherwise very clean Lua code is also an annoyance though.  While it was certainly less elegant, I think 5.1's handling had real practical advantages over 5.2's --  if you forget to about the newline handling in 5.1, you'll get a parse error, but if you forget to add a semicolon in 5.2, you'll get a runtime bug.  Parse errors tend to be far easier to detect and fix.

-Sven