Discussion Thread: DIP 1033--Implicit Conversion of Expressions to Delegates--Final Review

FeepingCreature feepingcreature at gmail.com
Wed Nov 25 09:05:44 UTC 2020


On Tuesday, 24 November 2020 at 17:12:38 UTC, Paul Backus wrote:
> On Tuesday, 24 November 2020 at 09:47:33 UTC, FeepingCreature 
> wrote:
>>
>> Could DIP1033 offer something like ...
>>
>> inout(T) get(DG : inout(T) delegate())(DG fallback) pure { ... 
>> }
>>
>> Where DG would carry callsite inference about nothrow and 
>> @safe ness of the converted expression?
>
> As I understand it, with DIP 1033, a call to your example `get` 
> function like `myNullable.get(123)` will deduce `DG` to be 
> `int` (as it currently would), but it will instantiate 
> successfully instead of failing, because `int` will now have an 
> implicit conversion to `inout(int) delegate`. At runtime, the 
> argument will be evaluated eagerly unless you explicitly wrap 
> it in a delegate (e.g., with `() =>`).

Ah crud, yeah.

Damn. It would be *really valuable* to have a way to actually 
combine lazy with @safe, pure, nothrow etc.


More information about the Digitalmars-d mailing list