Can you elaborate more on the conflict between "continue" and the lexical scoping?
On Thu, May 12, 2022 at 11:25 AM Javier Guerra Giraldez wrote:
a usable continue keyword has some ugly interactions with true lexical scoping, so ironically the `goto` is the cleaner way.
Probably the "lexical scope" problem is about "repeat-until" loop in Lua:
if ... then continue end
local finished = ...
Here "continue" is impossible to implement (both as a keyword and a goto-label) as it jumps inside the scope of the local variable "finished".
The language design choice was to
- either disallow referring inner local variables in the "until" condition (you have to define "finished" variable before "repeat")
- or disallow the "continue" keyword.
IMO, the ability to use inner locals in the loop exit condition is a much more useful feature than "continue" keyword.
Of course, Lua can disallow using the "continue" keyword in some loops and allow it in other loops, but it looks too weird to be included in the language, instead another weird but versatile operator ("goto") was introduced.
Now perfectionists want to either remove "break" or introduce "continue", because both these operators are just a hidden "goto" :-)