Hi folks,
A somewhat philosophical language design question for you:
Should while/for loops' "continue" be dynamically or lexically
scoped? How about "break"?
I asked this on the bug tracker at
https://savannah.gnu.org/bugs/?55995
and Rik sent me over here to get a bigger audience.
The current situation is this: continue is dynamically scoped,
but break is lexically scoped. This means that a break can only
be used inside the text of an actual for/while loop, in the same
function that defines it. But you can call continue anywhere,
and it will look up the function call stack and affect the
execution of a for/while loop in a calling function.
Personally, I lean towards "continue" being lexically scoped, so
you can always see where it happens while you're looking at the
source code of the function that contains the for loop.
Non-local affects on control structures are harder to understand
and debug. (This is why some developers dislike exceptions.)