Generator issue: exceptions while initializing arguments
Kevin Smith
khs4473 at gmail.com
Mon Sep 10 10:50:17 PDT 2012
>
> > function f(x=EXPR1, y=EXPR2) { BODY }
> > ===>
> > function f(x, y) {
> > if (x === void 0) x = EXPR1;
> > if (y === void 0) y = EXPR2;
> > BODY
> > }
>
> In case it isn't clear what I'm saying here, I think the same
> desugaring should hold for generators. Exceptions would then be
> deferred to "loc 2" in Allen's example.
>
I'm not so sure - the desugaring above would mean that default expressions
would have visibility across curly-brace boundaries, which I find to be
quite surprising. That's what makes "var" so weird, after all. The
conceptual link between curlies and visibility is inherent in C-like
languages.
Moreover, curlies surrounding a function body have an even
stronger connotation of isolation than statement block curlies.
IMO the expectation will be that default parameter values are evaluated
when the generator function is called. Any exceptions that occur in the
generator body prior to the first yield will be expected at the first call
to next().
Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120910/5b6d682a/attachment-0001.html>
More information about the es-discuss
mailing list