Generator issue: exceptions while initializing arguments

Brendan Eich brendan at mozilla.org
Fri Sep 14 19:12:47 PDT 2012


Kevin Smith wrote:
> What I'm questioning now is the idea that, in generators, the implicit 
> first yield should occur *before the defaults are evaluated*.  I don't 
> think that's a tenable position.  Is there an implementation problem 
> with inserting the implicit first yield *after* the defaults are 
> evaluated but *before* the rest of the function body?

Not particularly, and this was where I landed at first.

In the SpiderMonkey implementation, at first, the bytecode emitter emits 
the implicit yield opcode (JSOP_GENERATOR) before all other generated 
code. But since then some conditional opcodes are emitted even before 
the implicit yield:

http://dxr.mozilla.org/mozilla-central/js/src/frontend/BytecodeEmitter.cpp.html#l2620

Other implementations may generate different intermediate or target 
forms from source, but I think the choice of where to put the implicit 
yield can be made either way without hardship.

Other implementors should weigh in.

/be


More information about the es-discuss mailing list