[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A tiny matter of style
- From: Sean Conner <sean@...>
- Date: Wed, 9 May 2018 15:44:01 -0400
It was thus said that the Great Lorenzo Donati once stated:
> I wouldn't mind if Lua allowed an optional syntax for specifying what
> "end" ends; optional but enforced if used, i.e. an error would be issued
> if (say) "end for" didn't end a for structure.
> I can't say if it would be too heavy for the compiler or if a nice
> syntax could be devised that didn't render the grammar too complicated
> For example:
> end for (ambiguous)
> end for;
> end ---for (semantic comments?)
> end ::for:: (fake label? ambiguous)
> <choose your poison!>
Here are some other options:
function() ... endfunction
if ... then ... endif
while ... do ... endwhile
for ... do ... endfor
do ... enddo -- hmm ...
function() ... noitcnuf
if ... then ... fi
while ... do ... elihw
for ... do ... rof
do ... od --- hmm ...
The do keyword is problematic. Several constructs use it, but it can be
used on its own to intruduce a new lexical scope.
In my own code, I don't think I've ever used a semicolon.