Thread overview | |||||
---|---|---|---|---|---|
|
March 04, 2007 proposal : functions->delegates | ||||
---|---|---|---|---|
| ||||
Hi, IMHO the compiler should be able to implicitly convert function-pointers into delegate-pointers. Before the delegate is passed as argument, the context-pointer is filled in. Now when I pass a function, the context-pointer could simply be filled with null. A problem will be, where to store the context-pointer in a function, as it has no context-pointer (to preserve compatibility with C). Or the compiler could implicitly create an anonymous delegate around that function. |
March 04, 2007 Re: proposal : functions->delegates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thorsten Kiefer | Thorsten Kiefer wrote: > Hi, > IMHO the compiler should be able to implicitly convert function-pointers into delegate-pointers. > Before the delegate is passed as argument, the context-pointer is filled in. > Now when I pass a function, the context-pointer could simply be filled with null. At the moment it can't, since delegates and function-pointers have incompatible calling conventions. > A problem will be, where to store the context-pointer in a function, as it has no context-pointer (to preserve compatibility with C). There's another thread on that, "D 2.0 - dalegates to function" > Or the compiler could implicitly create an anonymous delegate around that function. That would be a good transitional solution, but because it involves an extra function call, I'd still hope the delegate and function-pointer calling-convention can be made compatible. L. |
March 04, 2007 Re: proposal : functions->delegates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lionello Lunesu | Lionello Lunesu Wrote: > Thorsten Kiefer wrote: >> Hi, IMHO the compiler should be able to implicitly convert function-pointers into delegate-pointers. Before the delegate is passed as argument, the context-pointer is filled in. Now when I pass a function, the context-pointer could simply be filled with null. > > At the moment it can't, since delegates and function-pointers have incompatible calling conventions. Well, it certainly used to work under at least some platform/compiler combinations. I've looked, and it would appear to be a mere matter of whether a context pointer is pushed to the stack as well. The ABI doesn't make it clear whether parameters/local variables are addressed from the bottom or the top of the stack frame. From my experiment, it would appear to be the bottom. <snip> > That would be a good transitional solution, but because it involves an extra function call, I'd still hope the delegate and function-pointer calling-convention can be made compatible. Indeed. And one way that's been suggested is to pass the context pointer in a register rather than pushing it to the stack. Stewart. |
Copyright © 1999-2021 by the D Language Foundation