Just to be sure: whether or not an error is passed to a callback, the
final callback is always called?
I mean, the last callback could also be called *only when something fails*, a bit like a default case in a switch, or an error-handling
routine.

Yes, the final callback is always called, but if an error is passed to the callback by any of the main steps in the "sequence ladder", it will immediately jump to the final callback and not execute further steps.

What do you mean? The compiler does deduce the type of Funcs.

If you look at where I call Waterfall() in main, you'll see I had to manually specify (Callback cb) instead of just (cb); since it didn't know that the Funcs... were of type AsyncFunc

What do you mean by 'specialize'?

That is to say, there is no way I can see, to say that the variadic template parameter "Funcs..." are all AsyncFunc's. I think I noticed that in Swift you can say something like "Funcs:AsyncFunc..." to specialize the variadic. No swift expert, but was just browsing around today trying to compare how you might do it in C++ or other languages.

(cb) { cb(null, "one");} is possible, but that means it's a function
template, not a function.
You can get this syntax by making the callbacks template arguments, which means they must be known at compile-time. Is that OK with you or
do you need the possibility to define the callbacks at runtime?

The goal was to do as much as possible at compile time. Could you elaborate on this a bit. I guess the answer is, yes, it's okay with me.

I don't get it: none of your callbacks have a return type per se: they
all return 'void'.
Do you want callbacks that really return something?

Yes, the callbacks at step0 should output a type in the result which is specific to step0, and then that type should be fed in as a secondary parameter to step1.

I didn't get that far, as I was already stuck.

You can test if func[0] takes one or two arguments:

import std.traits: isCallable, ReturnType;

static if (isCallable!(Func[0]) && ReturnType!(Func[0]).length == 1)

Ah, yes, that sounds reasonable, I already thought something like that may do the trick.

thanks for your patience!

Reply via email to