ta0kira / zeolite

Zeolite is a statically-typed, general-purpose programming language.
Apache License 2.0
18 stars 0 forks source link

Disallow `break` and `continue` in `cleanup`. #125

Closed ta0kira closed 3 years ago

ta0kira commented 3 years ago

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.