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

Paul Backus snarwin at gmail.com
Tue Nov 24 17:12:38 UTC 2020

On Tuesday, 24 November 2020 at 09:47:33 UTC, FeepingCreature 
> 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 `() =>`).

More information about the Digitalmars-d mailing list