DIP 1016--ref T accepts r-values--Formal Assessment

Daniel N no at public.email
Sun Feb 10 10:57:30 UTC 2019


On Saturday, 9 February 2019 at 01:31:05 UTC, H. S. Teoh wrote:
>
> Using lowering to lambdas as a way of defining semantics is not 
> the same thing as actually using lambdas to implement a feature 
> in the compiler!
>
> While it can be convenient to do the latter as a first stab, 
> I'd expect that the optimizer could make use of special 
> knowledge available in the compiler to implement this more 
> efficiently. Since the compiler will always use a fixed pattern 
> for the lowering, the backend could detect this pattern and 
> optimize accordingly.  Or the compiler implementation could 
> lower it directly to something more efficient in the first 
> place.
>
>
> T

The lambda even correctly handles "@disable this(this);", I like 
it!

struct One { @disable this(this); }
void fun(ref One one) { }

One gun() { return One.init; }

void main()
{
   One one; one.fun();
   (One __temp0){ return fun( __temp0 ); }(gun()); // OK
}



More information about the Digitalmars-d-announce mailing list