fork download
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));
}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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))
stdout

Standard output is empty