Open tshemsedinov opened 6 years ago
I don't like the idea of using utf8 symbol you can't easily write from the keyboard and have to copy paste (μ). As for the syntax, I find just using arrays much clearer as to what's going on. This syntax is cluttered with parentheses that hide the actual meaning too much imo. Perhaps at least:
const { seq, par } = require('metasync');
const f = seq(f1, par(f2, seq(f3, f4), f5), f6);
f((err, result) => {
console.dir(err, result);
});
I saved proposal from @primeare here just for notes, @lundibundi
We have no solution to distinguish sequential composition and composed function call, because f
have a same contract with f6
, so should we compose or start execution on next ()
. But maybe it will be used in future or will give inspiration to someone.
@lundibundi I like arrays too, because it all other syntax will finally save calls to data structures (most likely those arrays) and then will iterate executing seq/par
. Arrays are enough expressive so no need to build arrays implicitly.
@lundibundi
I don't like the idea of using utf8 symbol you can't easily write from the keyboard and have to copy paste (μ).
FWIW, even if you don't setup AltGr or whatever it's called on your system (which you probably do, because you can't even enter em-dashes (—) from the keyboard otherwise; on Macs, for example, it is set up by default, so µ is just Option+m), you can enable Greek input method and enter µ as switch to Greek, m, switch back to English.
I agree that a non-ASCII name shouldn't be the only one for a function, but a convenient Unicode alias does sound like a good idea to me.
Well, if it's an alias I'm fine. I don't want a unicode symbol to be the only way of accessing the function.
@primeare why [2, 3]
? What does it mean? All returning from μ
functions will have callback-last
contract and all callbacks will have error-first
.
Do you mead μ(f1)
will return single-argument function (callback) => ()
like this?
@primeare please prepare PR so we can test it in CI and compare with current implementation syntactically and by performance.
Syntax idea by @primeare, modifications by @tshemsedinov
Known problems:
μ(f3)(f4)
in example.