fork download
  1. import std.stdio;
  2.  
  3. struct carry(TResult, TParams...) {
  4. public this(TResult delegate(TParams) _f) {
  5. f = _f;
  6. }
  7. public auto opCall(TParams[0] para) {
  8. static if (TParams.length > 1) {
  9. return carry!(TResult, TParams[1 .. $])( (TParams[1 .. $] args) { return f(para, args); } );
  10. } else {
  11. return f(para);
  12. }
  13. }
  14. public TResult delegate(TParams) f;
  15. }
  16.  
  17. void main() {
  18. auto f = carry!(int, int, int, int, int)( (int a, int b, int c, int d) { return a+b+c+d; } );
  19. writeln(f(1)(2)(3)(4));
  20. }
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