On Thursday, January 03, 2013 17:59:22 deadalnix wrote:
> On Thursday, 3 January 2013 at 16:43:06 UTC, bearophile wrote:
> > deadalnix:
> >> I still have code broken all over the place.
> > 
> > D2 is getting its corner case problems sorted out and fixed,
> > but this still causes some breakage in user code. As more
> > people use D2, issues are found, discussed and fixed, the
> > breakages will get more and more uncommon.
> 
> Is this breakage intended ? To me it doesn't make sense, the
> generated code is :
> 
> (Bar bar = Bar.init; , bar).this()

It is most definitely intended. ref requires an lvalue. A struct literal is a 
temporary and therefore should be an rvalue, not an lvalue.

Before, you had the stupid situation of

foo(Bar()); //compiles
foo(funcWhichReturnsBar()); //fails to compile

Both are dealing with temporaries, so both should be rvalues, and neither 
should compile. You need an actual variable or other non-temporary memory 
location (e.g. dereferenced pointer) if you want to pass an argument to a ref 
function. The previous behavior was broken and should have been fixed ages ago.

- Jonathan M Davis

Reply via email to