3 ms·
> In RAII languages[0], you obviously don't need unrestricted gotos. You don't need them for teardown, but they still make sense for retries -- cases where a p
by kentonv 4y ago
> In RAII languages[0], you obviously don't need unrestricted gotos.
You don't need them for teardown, but they still make sense for retries -- cases where a procedure needs to start over after hitting certain branches, e.g. a transaction conflict. I think `goto retry` is a lot more readable than wrapping the procedure in `do { ... } while (false)` and using `continue` to retry.
`goto` works very nicely with RAII here in that it'll invoke the destructors of any local variables that weren't declared yet at the point being jumped back to.