August 14, 2006 Re: Bind object to member function | ||||
---|---|---|---|---|
| ||||
> If you're looking for pointers to member functions to implement some sort of dispatch mechanism, delegates do not directly allow this. Thanks. Delegate is very cool, but it bind too early. |
August 14, 2006 Re: Bind object to member function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Li Jie | Li Jie wrote: > > If you're looking for pointers to member functions to implement some > > sort of dispatch mechanism, delegates do not directly allow this. > > Thanks. > Delegate is very cool, but it bind too early. My own Pyd library requires this functionality to implement its class wrapping. I do not endorse this practice, but the dirty hack it uses to get the functionality is found here: http://dsource.org/projects/pyd/browser/trunk/infrastructure/pyd/dg_convert.d In essense, it constructs a delegate from an Object instance and a regular function pointer. It takes advantage of how delegates are represented internally, but this behavior is not guaranteed by the spec. It is therefore firmly in the realm of "dirty hacks." Note that this module requires the ftype module originally written by Daniel Keep. The version of ftype in Pyd is slightly modified from his original. -- Kirk McDonald Pyd: Wrapping Python with D http://dsource.org/projects/pyd/wiki |
Copyright © 1999-2021 by the D Language Foundation