by lelanthran · 2y ago · 0 comments
The idiom `if (error) goto cleanup` is about the only thing I see goto used for. What flow control replaces that other than exceptions?
All of them are better served with more specialized language constructs but as a widely applicable hammer goto is pretty nice.
I don't expect C to have good error handling or generators any time soon but with goto I can deal with it.
Something like libprotothreads can't actually be implemented in a language that doesn't have gotos, so yeah, I see the need for it.
defer has gained in popularity for that situation.
Though gcc supports cleanup functions, just not very ergonomically.