HE Shi-Jun
HE Shi-Jun
@jiyinyiyong 理解意思就好。 @zensh 你完全没有理解“反复使用”的意思。promise代表了一个最终完成的值,所以它很容易被传递和分别使用。你看你写的thunks里fn1、fn2、fn3必须被捏到一个函数里,而前面promise的版本fn*可以是在别的接受promise的函数里附加到这个promise上的。 来一个稍有结构的例子: ``` js var numbers = [1, 2, 3] for (var i = 0; i < SIZE; i++) numbers.push(inputNumber()) showNumbers(numbers) showAvg(numbers) function inputNumber() { // return...
答@zensh 在我的例子里,showNumbers和showAvg都是确定的需求。也就是一个(不管是不是异步的)结果可能被多个地方用到,这不是很正常的吗?在debug里开显然不是符合要求的方式。debug设施和本身的语义不可混为一谈。 showNumbers对数据处理是不是对其他产生影响?显然是不影响的,因为你拿到的是最终的值,不可能影响之前的resolve/reject步骤。至于说,如果最终值是一个引用,如果多个地方持有相同引用,可以通过引用改变属性,这是对象引用的语义问题,跟promise毫无关系,跟异步毫无关系。即使在完全同步的编程里你也有一样的问题,所以编程里我们要对参数做保护性拷贝,或者有struct等自定义值类型的语言(js将来也会有)会传递值类型而不是对象引用,或者虽然是对象但是用Immutable模式。总之,你不要老是把完全不同层面的问题混到一起。
Consider the common use cases (if i can deal with the value of `function.sent`, process it in current generator, or delegate to sub generator), I think we need a ergonomic...
> It makes no sense to be to have it be "consumeable". I'm not sure whether "consumable" is good or bad, but it's really consuming values from `next(value)` in `function.sent`...
The essential problem of this issue is, currently `yield* g` will always start g with `g.next(undefined)`, changing that to `g.next(function.sent)` (if keep the syntax untouched) is theoretically a breaking change,...
> so i don't think that's a reasonable thing for us to be concerned about. I'm not sure about that. If a big site had such code (of coz I...
Yeah I also expect it to be A, but it means even a function is marked as "sensitive" (assume have the same behavior as "hide source" in `toString()` usage), the...
copy from @hax 's comment: https://github.com/tc39/proposal-decorators/issues/40#issuecomment-369867557 --- The best solution for the hoisting problem I can imagine is transform ```js @deco function f() { funcBody } ``` to ```js function...
copy from @rbuckton 's comment: https://github.com/tc39/proposal-decorators/issues/40#issuecomment-370010647 --- @hax, your example only works if the decorator deals with the function's execution, but not if the decorator augments the function object itself....
Copy from @trotyl 's comment https://github.com/tc39/proposal-decorators/issues/40#issuecomment-370124254 --- @rbuckton The third option won't work with circular dependency in ES module. Given the scenario: ```js // main.mjs import './f'; // f.mjs import...