lua-users home
lua-l archive

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



Probably a better method is to make your intent explicit with a semicolon:

f(a);
(g or h)(b)


This was how I first handled these cases.  However, I started running into problems anytime I edited my code; if you add a new line below f(a);, or copy (g or h)(b) to some other location, you need to adjust the semicolons appropriately, and that becomes a hassle.

After some frustration, I started writing lines like this:
f(a)
; (g or h)(b)

Using that pattern, the weird semicolon reminds me that I'm dealing with a line that needs protection from prior function calls -- and I can copy/paste that line safely.  The funny semicolons lead to ugly code though.

After working with the language for a while, my sense is that needing to worry about when statements end is one of the prices we have to pay for lua's clean, mostly semi-colon free syntax.  I don't particularly like the idea of adding an obscure parse rule to the language.  But, I'm starting to think that this may be one of the cases where such a rule could actually be a good idea.

-Sven