First Draft: opUnwrapIfTrue
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Thu Sep 17 00:19:36 UTC 2026
On 17/09/2026 2:15 AM, Paul Backus wrote:
> 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
Also the whole concept of using a loop to represent a conditional action
is overkill. It won't produce good assembly, nor does it represent what
you are doing with it.
Hence why we are killing off the range operators on Nullable for
PhobosV3. (I confirmed this with Adam, it was lead by Paul).
More information about the dip.development
mailing list