Library writing - delegates or fp's?
BCS
BCS at pathlink.com
Tue Jul 25 12:45:55 PDT 2006
Don Clugston wrote:
> BCS wrote:
>
>> Chad J wrote:
>>
>>> So I have decided to roll my own GUI library, one dedicated to
>>> computer games. But I've run into a bit of an unpleasant design
>>> problem - for handling callbacks, how should my library expose
>>> function pointers and delegates?
>>>
>> [...]
>>
>> a while back someone found out that you can take a delegate and
>> replace the internal function pointer with a regular function pointer
>> and it still works just fine.
>
>
> It works fine *most of the time*. IIRC, sometimes it will result in
> incorrect code. We could deal with those cases if we knew the exact
> circumstances under which function parameters are passed in registers.
> But until the ABI gets formalised, it's a non-portable hack that
> occasionally fails.
I wouldn't use it (if possible) even if it was portable. The compiler
should do this for you.
cast(delegate)fnpt;
More information about the Digitalmars-d-learn
mailing list