Generator issue: exceptions while initializing arguments

Jason Orendorff jason.orendorff at gmail.com
Sun Sep 9 18:50:21 PDT 2012


On Sat, Sep 8, 2012 at 3:01 PM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
> This is the first of probably several semantic issues WRT generator that
> will need to be resolved in the spec.

I mentioned this to David Herman when we started implementing default
parameters.

What I think is that default parameters should be specified to be as
much like the following desugaring as possible:

    function f(x=EXPR1, y=EXPR2) { BODY }
    ===>
    function f(x, y) {
        if (x === void 0) x = EXPR1;
        if (y === void 0) y = EXPR2;
        BODY
    }

Here is my rationale:
* The question is really about the semantics of default params,
  not generators.
* Default parameters are a convenience feature:
  certainly welcome and useful, but not powerful,
  and thus by the principle of least astonishment
  they should in fact be skin-deep.

I think this is what Brendan's saying as well.

SpiderMonkey's current implementation of default params isn't quite
right in a few ways. I'll file some bugs and we'll get after it.

-j


More information about the es-discuss mailing list