Looks good. Long term the conversion function -> delegate should be put
in the language, but David's code seems to do the trick for the time being.
I'll leave this up to Walter. Walter, do you have the time to implement
the function -> delegate implicit conversion? If not, I suggest we let
David add his code to Phobos, either in std.typecons or std.functional.
One personal preference: instead of delegateFromFunc I prefer toDelegate
as it's a tad more in sync with other names.
Thanks David!
Andrei
David Simcha wrote:
A pretty significant wart of D is that function pointers and delegates
are completely incompatible. I've come up with a good hack to convert
function pointers to delegates without any heap allocations or
additional storage besides the delegate itself being used. In
particular, there are no heap allocations, closures, etc. involved.
However, calling a delegate created from a function pointer does still
incur two indirect function calls instead of one. I've attached the
code. Tell me what you think.
------------------------------------------------------------------------
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos