return was disallowed previously due to ambiguities; however, break and continue are currently allowed in cleanup.
What should the behavior here be?
call () {
while (true) {
cleanup {
break
} in {
return foo
}
}
return bar
}
Currently, the break will supersede the first return (after the return value is set) and will break out of the loop. This means that bar will be the actual value returned.
I guess there really isn't a good reason for cleanup to do any sort of jump; it's mostly to ensure that a subroutine gets executed whenever something within in jumps over the statements that directly follow the in.
It's a bit more straightforward to consider fail, since fail makes a bigger jump than return does. For example, you could fail if a particular returned value doesn't meet a particular requirement.
return
was disallowed previously due to ambiguities; however,break
andcontinue
are currently allowed incleanup
.What should the behavior here be?
Currently, the
break
will supersede the firstreturn
(after the return value is set) and willbreak
out of the loop. This means thatbar
will be the actual value returned.I guess there really isn't a good reason for
cleanup
to do any sort of jump; it's mostly to ensure that a subroutine gets executed whenever something withinin
jumps over the statements that directly follow thein
.It's a bit more straightforward to consider
fail
, sincefail
makes a bigger jump thanreturn
does. For example, you couldfail
if a particular returned value doesn't meet a particular requirement.