Closed Mercerenies closed 2 years ago
fd17df6 implements these two keywords.
For the moment, at least, they are language primitives, and we have a special ad-hoc check to make sure they are (a) in a loop, and (b) not inside a closure that blocks us from the loop. If we get some more syntactic awareness within macros, we'll definitely revisit the idea of making them macros. But the feature is available now, so this issue is closed.
Currently, we have no way of using the Godot control flow
break
andcontinue
statements.Now, we could naively implement them as keywords, but there is another option, provided we implement #19.
We could change
while
toimpl-while
(or some other esoteric name) and letwhile
be a macro that expands roughly as follows.And the same for
for
. That way,break
andcontinue
can only be used inside of the appropriate constructs, and we can verify that at compile-time. Of course, this won't stop you from using them in a closure inside of awhile
, which is harder to detect. So it's possible that doing the check halfway would just confuse people further.