domenic at domenicdenicola.com (2013-07-19T15:33:15.523Z)
On 7/15/2013 10:24 AM, Jeremy Martin wrote:
> Correct me if I'm wrong, but wouldn't the lexical-scoping restraint 
> satisfy the shallow generator requirement?  As I understand it, the 
> issue with deep generators and CPS transformations is that the 
> transformations have to be applied to functions that aren't even 
> lexically inside the GeneratorFunction.  Additionally, can't the 
> nested CPS transformations issue by alleviated with a reference to the 
> GeneratorFunction stack frame itself (a la SpiderMonkey)?
Consider the following:
```js
function* yieldEach(array){
 array.forEach(n => {
   yield n;
 });
}
```
In order for this to work, not only does `yieldEach` have to be 
suspended for the inner yield, but forEach does as well. That means CPS 
transforming functions based on whether they call a yielding function.
On 7/15/2013 10:24 AM, Jeremy Martin wrote: > Correct me if I'm wrong, but wouldn't the lexical-scoping restraint > satisfy the shallow generator requirement? As I understand it, the > issue with deep generators and CPS transformations is that the > transformations have to be applied to functions that aren't even > lexically inside the GeneratorFunction. Additionally, can't the > nested CPS transformations issue by alleviated with a reference to the > GeneratorFunction stack frame itself (a la SpiderMonkey)? Consider the following: function* yieldEach(array){ array.forEach(n => { yield n; }); } In order for this to work, not only does `yieldEach` have to be suspended for the inner yield, but forEach does as well. That means CPS transforming functions based on whether they call a yielding function.