language: D (dmd) (dmd-2.042)
date: 334 days 18 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import std.stdio;
 
struct carry(TResult, TParams...) {
        public this(TResult delegate(TParams) _f) {
                f = _f;
        }
        public auto opCall(TParams[0] para) {
                static if (TParams.length > 1) {
                        return carry!(TResult, TParams[1 .. $])( (TParams[1 .. $] args) { return f(para, args); } );
                } else {
                        return f(para);
                }
        } 
        public TResult delegate(TParams) f;
}
 
void main() {
        auto f = carry!(int, int, int, int, int)( (int a, int b, int c, int d) { return a+b+c+d; } );
        writeln(f(1)(2)(3)(4));
}
prog.d(19): Error: constructor prog.carry!(int,int,int,int,int).carry.this (int delegate((int, int _param_0, int _param_1, int _param_2)) _f) is not callable using argument types (int)
prog.d(19): Error: cannot implicitly convert expression (1) of type int to int delegate((int, int _param_0, int _param_1, int _param_2))
prog.d(19): Error: cannot cast int to int delegate((int, int _param_0, int _param_1, int _param_2))
prog.d(19): Error: constructor prog.carry!(int,int,int,int,int).carry.this (int delegate((int, int _param_0, int _param_1, int _param_2)) _f) is not callable using argument types (int)
prog.d(19): Error: cannot implicitly convert expression (2) of type int to int delegate((int, int _param_0, int _param_1, int _param_2))
prog.d(19): Error: cannot cast int to int delegate((int, int _param_0, int _param_1, int _param_2))
prog.d(19): Error: constructor prog.carry!(int,int,int,int,int).carry.this (int delegate((int, int _param_0, int _param_1, int _param_2)) _f) is not callable using argument types (int)
prog.d(19): Error: cannot implicitly convert expression (3) of type int to int delegate((int, int _param_0, int _param_1, int _param_2))
prog.d(19): Error: cannot cast int to int delegate((int, int _param_0, int _param_1, int _param_2))
prog.d(19): Error: constructor prog.carry!(int,int,int,int,int).carry.this (int delegate((int, int _param_0, int _param_1, int _param_2)) _f) is not callable using argument types (int)
prog.d(19): Error: cannot implicitly convert expression (4) of type int to int delegate((int, int _param_0, int _param_1, int _param_2))
prog.d(19): Error: cannot cast int to int delegate((int, int _param_0, int _param_1, int _param_2))