lua-users home
lua-l archive

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


 
f()
(g or h)()

is naturally read as 2 statements, though given Lua's grammar it should be parsed as just one.  Lua 5.1 was newline sensitive: it would throw an error if an otherwise complete _expression_ was continued by a newline, followed by an open paren.  Lua 5.2 removed the check.

My feeling is that this was a bad change -- I've never come across a case where the error was triggered by bug-free code.
 
Well, in my LuaBrainFuck library [1] the Lua 5.2 disambiguation is heavily used !
Although I do not pretend the this library is very useful for everyday programming.
Look at the "99 bottles of beer" bracket mode code [2] for example.
There are a number of lines ending with a closing parenthesis while the following lines open a new parenthesis.

[1] https://github.com/prapin/LuaBrainFuck
[2] https://github.com/prapin/LuaBrainFuck/blob/master/test/99-bottles-bracket.lua

--
-- Patrick Rapin
-- coauthor of "Le guide de Lua et ses applications", D-BookeR