1.0 ?? [templates and currying]

Walter Bright newshound at digitalmars.com
Mon Nov 6 16:53:05 PST 2006


Tom S wrote:
> Interesting ! :) Can it handle partial currying ?

I don't know.

> My Bind lib is also 
> about function/delegate currying, with arbitrary partial currying, 
> parameter swizzling and function composition. The only thing that it's 
> currently lacking is support of 'out', 'inout' and 'lazy' parameters. 
> But this cannot be done without more info from the compiler. Would it be 
> hard on your side to add more meta-info for functions and delegates ? 
> I'm sure many people would appreciate the ability to extract parameter 
> types, their count and a return value type for functions and delegates. 
> The current approach to obtain this kind of meta-info is well 
> demonstrated in the 'meta' package of Pyd: 
> http://www.dsource.org/projects/pyd/browser/trunk/infrastructure/meta

You are way, way ahead of me with this stuff. Wow!

BTW, I am considering changing the ==function and ==delegate is 
expressions, which you use, to the following:


==return gets the return type:

> template Return(dg)
> {
>     static if (is(dg R == return))
> 	alias R Return;
>     else
> 	static assert(0, "argument has no return type");
> }

==function or ==delegate gets the parameter types as a tuple:

> template Parameters(dg)
> {
>     static if (is(dg P == function))
> 	alias P Parameters;
>     else static if (is(dg P == delegate))
> 	alias P Parameters;
>     else static if (is(dg P == P*))
> 	alias Parameters!(P) Parameters;
>     else
> 	static assert(0, "argument has no parameters");
> }

This will require some adjustment in your code. I didn't think anyone 
was using that stuff. Will it be an issue for you? Or should I find 
another way to do it?



More information about the Digitalmars-d mailing list