DMD 0.174 release

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed Nov 15 11:45:20 PST 2006


Don Clugston wrote:
> I spent four months of my spare time getting something like that to work 
> in C++ for all compilers. But this is D. With tuples it's easy, you 
> could even say trivial!
> 
> R function(void *, U) makeCallable(R, U...)(R delegate(U) dg)
> {
>     return cast(R function(void *, U))dg.funcptr;
> }

According to http://www.digitalmars.com/d/abi.html , 'this' is passed 
*last*, not first. So then we get:

----
R function(U, void *) makeCallable(R, U...)(R delegate(U) dg)
{
     return cast(R function(U, void *))dg.funcptr;
}
----

As far as I can see, that should work on the following conditions:
* The input is not a variadic delegate.
* The return value is not a struct. (Except that on Windows it should 
work for 1,2,4 or 8-byte structs, but not for other sizes)

Haven't tested it though, I just thought something was off and checked 
the ABI ref.



More information about the Digitalmars-d-announce mailing list