Function to delegate conversion
BCS
BCS at pathlink.com
Mon Jun 26 15:39:24 PDT 2006
Kirk McDonald wrote:
> BCS wrote:
>
>> Kirk McDonald wrote:
>>
>>>
>>> The following dirty, dirty hack /appears/ to work, at least in this
>>> trivial case:
>>>
>>> import std.stdio;
>>>
>>> struct DG {
>>> Object instance;
>
> I think you mean:
>
> - void function() fn;
> + void* fn;
>
>>> }
Actually I did mean what I said, but what I meant (and said) was wrong.
[...]
>
>
> But yes, that is a good idea. Templatizing real_dg, however, is going to
> be a royal pain in the ass, but possible. With Daniel Keep's ftype
> module, we can get something like:
>
[...]
> Also not pretty, but it should work, insofar as this whole trick works.
>
> -Kirk McDonald
how about
<code>
int function(int, float, char[], Object) fnp = getFNP();
int delegate(int, float, char[], Object) dg;
DG* dgp = cast(DG*)cast(void*)&dg;
dgp.fn = cast(void*)fnp;
</code>
It's about as type safe as ASM (a.k.a. not at all) but it should work
cleanly (sorta).
More information about the Digitalmars-d
mailing list