First Draft: opUnwrapIfTrue

Paul Backus snarwin at gmail.com
Wed Sep 16 14:15:12 UTC 2026


On Wednesday, 16 September 2026 at 10:50:10 UTC, Quirin Schroll 
wrote:
> On Thursday, 26 February 2026 at 16:01:22 UTC, Paul Backus 
> wrote:
>> A better solution would be to redesign your API to combine the 
>> check and the access into a single operation, either with a 
>> higher-order function like […] an `opApply` overload:
>
> This is why I think we need loop-else. The idea is simple: A 
> loop-else runs if the loop had no iteration through its body. 
> An `if` would then, effectively, be a special case of a loop 
> that runs once if the condition is true and doesn’t run if it’s 
> false.

I would be hesitant to add a feature with the same syntax as 
Python's [loop `else` clause][1], but the exact opposite meaning.

[1]: 
https://docs.python.org/3/tutorial/controlflow.html#else-clauses-on-loops


More information about the dip.development mailing list