D calling convention

Christian Kamm kamm-incasoftware at removethis.de
Tue Oct 28 23:51:38 PDT 2008


> Christian Kamm wrote:
>> One point we couldn't understand though, is the reversal of parameters
>> when calling some D functions: Parameters are usually passed
>> right-to-left, except for nonvariadic D functions, where the order
>> changes to left-to-right.
>> 
>> What is the reason for it?

Walter Bright wrote:
> The reason is because I'd eventually like to specify the order of
> evaluation of function arguments as being left to right. So, for normal
> D functions, this makes for optimal code generation. The only time
> monkey business would have to happen would be to support the C calling
> convention or the variadic one.

What about generally passing left-to-right for D functions then?

If 

foo(a1,...,an) was passed as
(this), a1, ..., an, (_arguments), (hidden)

with the first parameter in EAX if possible, we'd have the neatness
of "member function pointers have context as first arg" and the possibility
of specifying left-to-right evaluation order easily. We'd lose the ability
to pass hidden in EAX though.




More information about the Digitalmars-d mailing list