Multiple return values

deadalnix deadalnix at gmail.com
Wed Jan 4 10:35:30 PST 2012


Le 04/01/2012 15:23, Andrei Alexandrescu a écrit :
> On 1/4/12 2:36 AM, Manu wrote:
>> Regardless, I'd like to put a strong +1 towards proper multiple return
>> values. The point is NOT just to have the syntactical feature (ie.
>> struct return value semantics via tuples). The point is a language
>> guarantee that the architecture will do its best job to return each
>> value in consecutive registers OF ITS OWN TYPE, avoiding
>> allocation&writing to the stack. This is a common problem in C where the
>> only solution is to make functions inline or pay the cost of hitting the
>> stack (LHS hazard, very expensive on many RISC architectures).
>> It would lead to many optimisations in lots of code in my experience.
>
> Why make those optimizations only for multiple return values and not for
> every single returned structure?
>
> Andrei

I do agree with Andrei. Those are 2 orthogonals problems. The 
optimization problem is clearly something that can be improved in D ABI. 
Then, returning a tuple could be improved using thoses rules.

The multiple retur value problem is syntaxic sugar. It may be 
interesting, but not #1 priority.


More information about the Digitalmars-d mailing list