lua-users home
lua-l archive

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


Le mer. 3 juil. 2019 à 23:42, Soni "They/Them" L. <fakedme@gmail.com> a écrit :
If you indent with semicolons it'll never be an issue.

May be, but what horror !

And don't forget that programmers frequentlly have too long lines that they need to break
So these lines will NOT start by semicolons after the indentation.

Such convention of using semicolones at start of lines is never seen, much less readable than at end of instructions
And anyway the semicolon in Lua is neither an end of instruction or a start, but a separate no-op instruction, allowed in some contexts where other instructions are disallowed, such as after a return already "terminated" by a semicolon (so "return;;" is valid even if there are two no-op intructions, but "return;f();" is not with only the first ";" being correct) or after a goto, or after the end of a never ending loop (so "while true do... end;;" is valid, but "while true do... end;;f();" is not), or after any _expression_ or assignment statement that always terminates by n unconditional "error".

Note that if the _expression_ unconditionally terminates by an "error", you cannot even use it in an assignment instruction (because the assignment would never occur) or in the initializer of a "local" declaration (so "local a,b = 1,error" is invalid, and neither "a" or "b" would be initialized), as well you cannot use it in a "return" statement or in a subexpression in parentheses with other trailing or leading operators.

These crietria of validity of no-op ";" statement and "error" in expressions is only particlaly detected by the syntaxic parser; they are only detected by the downstream code flow analysis, but a compiler may still accept these constructs as valid and either drop silently of the extra code, or signal it to the programmer with a lint-like warning, or say that this code is most probably wrong and refuse to compile it (which is IMHO the best option).