[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: C-style "continue" keyword...
- From: sur-behoffski <sur_behoffski@...>
- Date: Sat, 18 Mar 2023 11:48:11 +1030
I really like C's "continue" keyword, as it lets me identify and handle
special cases at the top of a loop, leaving the coast (and indentation)
clear for meaty logic further down. (I deliberately abhor deep nesting,
as I believe that the layers of logic wrapping a line of code can make the
line harder to comprehend... this is why I always use 8-column indenting.)
If possible, I'd like to have a continue facility available across all
Lua 5.1 .. 5.4 versions. This is infeasible, as "continue" may be an
identifier within other scripts.
I use std.normalize (and std.strict) in all my scripts, trying to code
at the 5.1 level, but with semantics identical across the version spread.
Rock "bit32" is another example of trying to normalise across versions.
So, in an ideal world, I'd like to be able to require a new Rock, which
uses a (new?) hook provided by the VM, tied to a
possibly-mostly-compatible version of "continue": Perhaps "continue__"?
Sadly, I don't know enough about the VM(s) to know if this is feasible,
and, even if it was, I strongly suspect that the Lua team would be loathe
to revisit past versions.
At present, I use deep indentation as a strong hint that the code needs
to be refactored, probably using another function to reset the nesting
Hope this helps,