simple ABI change to enable implicit conversion of functions to delegates?
ag0aep6g via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 15 10:03:20 PDT 2017
On 05/15/2017 02:27 PM, kinke wrote:
> First of all, please don't forget that we're not only targeting X86, and
> that the args, according to the docs, shouldn't actually be reversed
> (incl. extern(D) - just on Win32, everywhere else the C ABI is to be
> followed).
As far as I see, it doesn't matter if the arguments are reversed or not.
The idea is to pass the context pointer in a way that doesn't affect the
other arguments. Put it in a spot that would otherwise be unused. I.e.,
if the arguments are not reversed, add the context pointer as a new last
parameter, and if the arguments are reversed, make it a new first
parameter.
> Then some ABIs, like Microsoft's, treat ` this` in a special way, not
> just like any other argument (in combination with struct-return), which
> would apply to method calls via a delegate with context = object reference.
This __thiscall thing, right?
https://msdn.microsoft.com/en-us/library/ek8tkfbw.aspx
So, `this` always goes in ECX in that case. Yeah, that's a problem, I guess.
But __thiscall is for C++, and we don't have to adhere to it in D, do
we? I mean, I know that D is supposed to (mostly) follow the C calling
convention of the system, but matching C++ is not a goal, or is it?
`extern(C++)` functions/delegates have to follow it, obviously. But then
we can just say that implicit conversion doesn't work with those.
> Some additional context: https://github.com/dlang/dmd/pull/5232
What I take from that is that changing the way arguments are passed
(particularly if they're reversed or not) is going to break a ton of stuff.
More information about the Digitalmars-d
mailing list