Template currying

Yuxuan Shui via Digitalmars-d digitalmars-d at puremagic.com
Thu May 5 16:45:55 PDT 2016


On Thursday, 5 May 2016 at 23:38:38 UTC, Ed wrote:
> On Thursday, 5 May 2016 at 23:19:59 UTC, Yuxuan Shui wrote:
>> On Thursday, 5 May 2016 at 23:12:40 UTC, Ed wrote:
>>> On Thursday, 5 May 2016 at 22:53:01 UTC, Yuxuan Shui wrote:
>>>> [...]
>>>
>>> alias aa(T) = a!(1,T);
>>> aa!ubyte(2);
>>>
>>> Your alias declaration is not correct.
>>
>> As you can see in my first post, I know how to make this work. 
>> I just think it'd be nice if compiler can do this 
>> automatically.
>>
>> Anothor point is that, what if I want to use partially 
>> instantiated templates as template arguments?
>
> My bad, I didn't read carefully "or not use alias:".
> With alias template parameter you can pass template:
>
> ------
> import std.stdio;
>
> template Foo(T,U){ T pop(){return T.max;}}
>
> alias Partial(U) = Foo!(U, string);
>
> auto bar(alias Whatever)()
> {
>     alias instance = Whatever!int;
>     return instance.pop;
> }
>
> void main(string[] args)
> {
>     writeln(bar!(Partial)());
> }
> ------
>
> 

Right, Partial!() works. I just want something more generic, like 
the Curry I proposed.

And I still think let the compiler do it is a good idea, because 
this could removes special cases in template arguments deduction


More information about the Digitalmars-d mailing list