Wanted: best way to express default expectations
ajieskola at gmail.com
Thu Oct 10 14:06:39 UTC 2019
On Thursday, 10 October 2019 at 13:36:05 UTC, Petar Kirov
> allows early stopping by having the iteration function return
> No.each to stop the iteration, but I'm not sure whether this is
> the thing you're looking for.
> If you're trying to solve a more general problem that would
> require the ability to return early from a nested scope I would
> also suggest checking opApply (may work for a simpler scenario)
> and Fibers, which when applied well can provide a substantial
> increase in expressive power.
These make possible to emulate `break` for the innermost range,
but still they only with loops (not try blocks or the whole
function body for example). And even in case of ranges, they
don't let one to `return`, `goto` or `break`/`continue` an outer
loop directly from the loop body.
And no, I'm not looking for a way to do it -an `if` statement can
do that like the first example shows. More like, i'm thinking an
`if` equivalent that'll execute the statement when NOT true.
Basically it would be like `assert`, except it would exit a code
block instead of terminating the program when it fails.
More information about the Digitalmars-d