On the richness of C++

Sean Kelly sean at invisibleduck.org
Wed Apr 16 13:42:48 PDT 2008


== Quote from Sean Kelly (sean at invisibleduck.org)'s article
> == Quote from Janice Caron (caron800 at googlemail.com)'s article
> > On 16/04/2008, Walter Bright <newshound1 at digitalmars.com> wrote:
> > >  The only way to merge function pointers with delegates is to have the
> > > compiler generate trampolines. This isn't very runtime efficient - the
> > > template approach will be faster.
> > I think that all that is being suggested is that function (that which
> > you get when you take the address of a static or global function)
> > should implicitly cast to delegate (that which you get when you take
> > the address of a local or member function).
> I think the problem is that functions and delegates are called differently.
> That is, the context pointer is passed as an invisible first parameter to
> a delegate, while functions have no such invisible argument.  Interestingly,
> because the first parameter of a D function is supposed to be passed in a
> register (EAX) on x86, I think you're right that it should be possible to
> allow such efficient conversion so long as the D calling convention
> accounts for it properly (and the platform supports such things).

Er... forget that.  A D function would obviously expect its first argument to
be in EAX regardless of whether it's a delegate.  Some conversion would be
necessary unless I'm missing something.


Sean



More information about the Digitalmars-d mailing list