Trying to reproduce Node.js async waterfall pattern.. (Meta-programming)
Philippe Sigaud via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jun 24 13:11:49 PDT 2014
On Tue, Jun 24, 2014 at 2:55 AM, Christian Beaumont via
Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:
> Just an idea that popped into my head... Maybe I can use variant for the
> input/output types? I haven't looked at it yet, so I'm not sure what it
> does, or the performance costs.
It imitates you standard variant type from dynamic languages. It sure
would make translating Javascript code easier.
I don't know its performance cost. I'd say the only way to know is to
compare your code with Node.js.
>
> I realized that because the final callback always gets called, and the types
> of the intermediate steps may be different, there is actually no way at all
> to define a completely uniformly type safe final callback...
Unless you define the final callback to be called only when an
exception is passed, as a special error-handling branch. Else the
chain would pass through the first function, then the second, up to
the Nth-1, and stop there.
More information about the Digitalmars-d-learn
mailing list