On Mon, Jun 20, 2011 at 10:50 AM, Dave Fugate <[email protected]> wrote:
> > http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls > [...] > > ** ** > > What’s not so clear though is when the offending FunctionDeclaration is > generated via an eval:**** > > “use strict”;**** > > try {**** > > eval(“function f() {}”);**** > > } catch(e) { /*should this be called?*/} > [...] > The million dollar question then is should “/*should this be called?*/” in > the snippet above be called or does the eval call succeed without throwing? > From ES5 alone, I would argue no exception should be thrown, but this isn’t > an ES5 feature per-seJ > Wow, good catch. That's an oversight -- I don't remember this case being noticed when we discussed this issue. I agree with your conclusion on three grounds: a) The anticipated cases of the prohibition in the note only narrows the Chapter 16 exemptions -- it only restricts how one can extend the language beyond what ES5.1 allows. This recommendation can therefore be followed by implementations that still fully conform to the letter of the ES5.1 spec. If we interpret the note the way you suggest, we preserve this compatibility. Otherwise, the note and the letter of the spec come into conflict. b) The text of the note recommends "Do not allow a *FunctionDeclaration* to occur in a *Statement* context." In your example, the FunctionDeclaration appears in a Program production as a SourceElement. This is not a Statement context. c) The hazard that motivates the note does not occur in this case, so there's no reason to stretch the restriction to apply to this case. So your conclusion in consistent with (a) the letter of ES5.1, (b) the letter of the note, and (c) the spirit of the note. +1. -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

