Hacker News new | ask | show | jobs
by jstimpfle 1431 days ago
> Your code is missing braces around the `if` blocks

Sure. It's obviously a sketch.

> If you put something between the loop and that, `break` would jump before that and also execute that.

Sure. But I rarely can see a need to make it so complicated (not in this case anyway). If you need multiple distinct cleanup sections that can't be inlined, then label them all (or put them in separate procedures) and jump to them explicitly. In my example, there is no need for any labels at all.

> this is a workaround for C's lack of automatic cleanup (RAII, garbage collection, python's `with` or whatever).

No need for workarounds here.