Converting function to delegate - was Re: How to know whether to use function or delegate
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Tue Jul 25 14:20:15 PDT 2006
BCS wrote:
> Frits van Bommel wrote:
>> Chris Miller wrote:
>>
>>> Isn't there an easier way to directly convert a function to a delegate?
>>
>>
>> Ehm, how about this:
>>
>> mydelegate = { somethingStatic(); };
>>
>> Seems pretty easy to me. Gotta love that new delegate syntax. :)
>> Gets a bit uglier once you add arguments though (especially if there
>> are more than a few).
>
>
> for(int i=0; i<0x100000 i++)
> mydelegate();
>
> lot-o-overhead. Copy all args to new stack frame, call-return, etc.
> Making a re-wrap-args and goto stub will save a bunch of time.
I believe Chris asked for an /easy/ way, not /the most efficient/ way.
If that's your thing though, I also posted some code that does that (for
simple cases) in a thread called "Question about x86 delegate calling
convention".
Google can't find it on digitalmars.com just now (at least not my post),
but here it is in the archives of the mailing list gateway at
puremagic.com:
http://lists.puremagic.com/pipermail/digitalmars-d/2006-July/005584.html
More information about the Digitalmars-d
mailing list