The stately := operator feature proposal

Timon Gehr timon.gehr at gmx.ch
Fri May 31 15:11:34 PDT 2013


On 05/31/2013 02:54 PM, Byron Heads wrote:
> ...
>
> The question is which is more optimal for the MRV style of programming
>
> // here the compiler can decide the best way to return the two ints,
> // probably in two registers, maybe even better for inlining
> (int, int) positionMRV() { return 1, 2; }
>
> // here the compiler is making a tuple and returning it may not be optimal
> #(int, int) positionTuple() { return #(1, 2); } //assuming #() for tuples
>
> I agree tuples cover more cases, but maybe hard to optimize for MRV.
> ...

No, this is false.

> a side note := could be use to extract tuples as well.
>
> Would be nice if _ was not a valid identifier, could have been used it
> for value skipping:
>
> x, _ := positionMRV(); // only care about x value, optimize away
>
>



More information about the Digitalmars-d mailing list