Re:We Are Sorry to Inform You (2005)
by bruce343434 on Saturday June 18, 2022 @09:19AM
(#31789575)
What is your proposed alternative for `defer`? (suppose hidden "RAII" control flow doesn't count)
It doesn't. Or, rather, RAII flow is strictly, explicitly better.
Re:We Are Sorry to Inform You (2005)
by munchenphile on Saturday June 18, 2022 @11:16AM
(#31790568)
Kotlin‘s return/break@<implicit or explicit loop label> handles the iterator escape idiom quite elegantly.
Re:We Are Sorry to Inform You (2005)
by dhzhzjsbevs on Saturday June 18, 2022 @11:36AM
(#31790807)
> This is lack of imagination
Code shouldn't require imagination. Sometimes the simple and readable solution is just better.
The "goto cleanup" idiom to do deferred work (I don't like defer or finally in languages which have them, but at least these are language constructs which say what we wanted, the goto cleanup idiom only achieves that in some very easy cases, in more complicated cases your actual intent will be unclear)
The "iterator escape" idiom to get out of some larger iterative operation we're doing because we just realised we want to give up / found the overall answer. This is lack of imagination in the language's / library's / eco-system's control flow semantics and is one reason I really like Rust's core::ops::ControlFlow.