Generator issue: exceptions while initializing arguments
Rick Waldron
waldron.rick at gmail.com
Mon Sep 10 10:20:48 PDT 2012
On Mon, Sep 10, 2012 at 1:08 PM, Brendan Eich <brendan at mozilla.com> wrote:
> Jason Orendorff wrote:
>
>> On Sun, Sep 9, 2012 at 8:50 PM, Jason Orendorff
>> <jason.orendorff at gmail.com> wrote:
>>
>>> 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
>>> }
>>>
>>
>> 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.
>>
>
> Agreed. My loc 1 initial reaction was based on the shallow preference for
> early vs. late errors in the contrived "thrower"
When you present the question without the generator + thrower, it makes
perfect sense that the exception would occur at loc 2 and I agree with this
behaviour as well.
Now for the conjecture, feel free to skip the following two paragraphs...
While I don't think "people won't get it" is an argument for anything, as a
representative of all web developers, I'm inclined to hold my position that
the exception will be expected at the call site, ie. loc 1. I say this
because I suspect that most developers will view the call site as "Part 1"
of the generator and the yields as "Part 2".
Now that I've made that case, I'd like to also state that it's perfectly ok
for us to say that generators are allowed to have different behaviour,
because they are a different thing.
Rick
> case.
>
> /be
>
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120910/a3a5a350/attachment.html>
More information about the es-discuss
mailing list