Multiple return values...

Timon Gehr timon.gehr at gmx.ch
Fri Mar 16 10:53:07 PDT 2012


On 03/16/2012 06:33 PM, Manu wrote:
> On 16 March 2012 18:37, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org <mailto:SeeWebsiteForEmail at erdani.org>>
> wrote:
>
>     Actually, as has been mentioned, swizzling can be done very nicely
>     inside the language.
>
>
> How?

Use opDispatch.

a = a.yxwz;

> The only example I saw in this thread was your from()/to()
> approach, which Timon said didn't actually work...?
>

It does work for assigning to simple variables, but not for assigning to 
more general expressions.

> ...
> In terms of benchmarks (the quantity of value you are looking for), it
> probably won't make so much difference to existing code, because people
> avoid returning structs by value like the plague It's just something you
> simply don't do. But if it were a real feature that were reliable, I can
> see it quickly replace returning through references passed in the
> parameter list (a horrible concept conceptually, effectively a hack),

DMD does that for you (Walter is the inventor of NRVO).




More information about the Digitalmars-d mailing list