On Wed, Feb 18, 2009 at 4:41 AM, Mark Meijer wrote:
> print("Statement 1");(false or print)("Statement 2")
>
> In this case, if I omit the semicolon, Lua complains about an attempt
> to call a nil value. Makes sense. It may become more difficult to
> interpret the error report, if the return value of Statement 1 is
> something callable. Personally, I always end my statements with a
> semi-colon. It's a paranoia thing, I guess, but evidently not entirely
> unwarranted :-o
The rule I try to follow is always put semicolons between statements
that exist on the same line (a rare case) but avoid whenever possible
putting semicolons between statements on separate lines. According to
these rules, one would never write
print("Statement 1") (false or print)("Statement 2")
but one might accidentally write
print("Statement 1")
(f or print)("Statement 2")
The error in the first example could conceivably be silent or detected
only at run-time. However, the error in the second example is more
benign since it is quickly detected by the compiler during parsing
("ambiguous syntax"). On discovering this, you can add the semicolon:
print("Statement 1")
;(f or print)("Statement 2")
I choose putting the semicolon in front of the first line. Starting a
line with a parenthesis is a red flag as is starting a line with a
semicolon.