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:21:38 PDT 2014
>> 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.
OK, replying to myself here :-)
I tried to code it with templates, but got to the point where result
types depend on runtime values (namely, is error null or not?), which
is not possible in D.
So I'd say, probably the easiest way to keep the null/error scheme is
to use Variant everywhere. That what I tend to do when converting code
from untyped languages anyway.
More information about the Digitalmars-d-learn
mailing list