[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A tiny matter of style
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Wed, 9 May 2018 21:18:41 +0200
On 09/05/2018 18:24, Egor Skriptunoff wrote:
On Tue, May 8, 2018 at 11:11 AM, Dirk Laurie wrote:
When the right-hand side of an assignment is an anonymous function, I
nowadays put a semicolon after the final "end" to distinguish it from
other uses of 'end'. Do you like the idea or hate it?
Some programming languages (e.g PL/SQL) have distinct syntax for "end"
depending on the statement:
if ... end if;
for k in 1..5 loop ... end loop;
case ... end case;
function FuncName ... end FuncName;
I often comment the end of scopes that span over about 15-20 lines,
especially when there are multiple nested scopes. For example
end -- for
-- more blah
end -- function MyFunc
end -- if
You get the gist of it.
It helps a lot when debugging or refactoring code.
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
end for (ambiguous)
end ---for (semantic comments?)
end ::for:: (fake label? ambiguous)
<choose your poison!>
Just rambling, not a well fleshed-out RFE anyway.
Do you want to achieve the same goal by appending a semicolon to "end"?