This is relevant. There are lots of real-life errors that come out of these errors and the worse mistakes people make trying to work around control flow (goto fail?).
I desperately want a 'break break' command. Not a label break, which is painful to work with, but an instruction to break the current loop and the outer loop.
I don't like the goto fail thing being discussed as an example of goto being evil. If they had used the other common pattern - returning -1 on failure - instead of the pattern they used, their code would look like this:
if (a)
return -1;
if (b)
return -1;
return -1;
if (c)
return -1;
return 0;
And literally the exact same issue would occur, even though goto wasn't used.
That works well except when you're in a language where you can't nest functions and need data from the outer scope. C is like that.
Rust really likes to bail out of functions when something goes wrong. That's what "try!()" does.
Allowing multiple exits from a loop is no longer controversial. Multiple entries into a loop are still considered undesirable.
From a proof of correctness standpoint, the topology requirement is that there be some single place within the loop through which control must pass. That's where the proof inductive step takes place, and where you prove loop termination by showing that some measure is decreasing. Restrictions stricter than that are more stylistic than formal.
Ah, you seem to be
talking about having the source code of function
X inside the source code of
function Y and, then, the names
known in function Y are also
known in function X unless
declared again within function
X. I LIKE that! That's what PL/I
has.
Once I got a phone interview from
Google. An early question was,
"What is your favorite programming
language?"
Sure, right away, PL/I! Opps, (from a movie) "way
wrong answer!". Apparently the
only right answer was C++. Gee,
I didn't want to lie. Besides, to me
saying C++ instead of PL/I should
cause me to lose a full letter grade!
So, PL/I has descendancy, static
and dynamic. The static version is
from the nesting in the static source code. The
dyanmic version is from functions,
subroutines, etc. that have been
called (are active) but have yet to
return.
Then with such descendancy and entry variables, can get
some interesting situations, design
patterns!
I did that once and avoided a
total mess in the IBM AI language
KnowledgeTool!
I desperately want a 'break break' command. Not a label break, which is painful to work with, but an instruction to break the current loop and the outer loop.