You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CoffeeScript's decision to infer generatorness from yield yields to orthogonality violation.
The following js snippet is semantically homogenous and correct:
This is achieved because so has signature described as follows:
typePromiseGena=a-> [Promise] -- consider generators that yields Promisesso::PromiseGena-> (a->Promise) -- convert generator to the function that returns a Promise-- Here monadic nature of Promise is omitted for simplicity
In contrast, the following CoffeScript counterpart will fail without changing the semantics of so()
so=require'so'fs=require'then-fs'case1=so->'Immediate'# fails since argument is not a GeneratorFunctioncase2=so->yieldfs.readFile'somefile.txt', 'utf8'combined=so->a=yieldcase1()
b=yieldcase2()
{a, b}
main=so->console.logyieldcombined()
main().done();
Generators without yield are strange in the case of generating sequences (i.e. using generators as intended), but are pretty valid corner case for asynchronous flow control based on generators.
So if CoffeeScript will release it's proposed semantics we should consider implementing so() argument check to be a GeneratorFunction and change it's semantics if it is not.
CoffeeScript's decision to infer generatorness from
yield
yields to orthogonality violation.The following js snippet is semantically homogenous and correct:
This is achieved because
so
has signature described as follows:In contrast, the following CoffeScript counterpart will fail without changing the semantics of
so()
Generators without
yield
are strange in the case of generating sequences (i.e. using generators as intended), but are pretty valid corner case for asynchronous flow control based on generators.So if CoffeeScript will release it's proposed semantics we should consider implementing
so()
argument check to be a GeneratorFunction and change it's semantics if it is not.Would appreciate any thoughts from @ForbesLindesay, @jashkenas, @Nami-Doc
The text was updated successfully, but these errors were encountered: