On Apr 19, 2011, at 11:02 AM, Garrett Smith wrote:
> I don't mean to annoy by repeating the same things, but here goes: Is
> `()` Grouping Operator or Arguments? Is `[]` ArrayLiteral or Property
> Accessor? Or do these cases depend on the preceding token?
It depends on the context, but ASI does not change the context.
> I'll take your prose on with an example Non error B behavior, b.js:
> (function() {
> /*...*/
> });
>
> Non-error A behavior, a.js:
> var MyWidget = function(){
> this.name = "mike";
> }
ASI happens here only if a.js is not concatenated.
> Now concatenate a.js and b.js and you have:
> var MyWidget = function(){
> this.name = "mike";
> }(function() {});
Yes. We've discussed this. It's not a change in semantics due to the
error-correction aspect of ASI. There is no ASI on this concatenated input!
> Which makes MyWidget undefined and sets window.name to "mike". That's
> all fine if you you notice it right away. But what if `MyWidget` gets
> called in a callback of some sorts, and that callback never fires?
> Well, sure, you might say that would be a lazy developer and faulty
> QA, but IMO it would be much nicer to be fail fast.
It's a hazard for sure, but for the umpteenth time, it is not due to ASI!
> That example, BTW, is in
> http://jibbering.com/faq/notes/code-guidelines/asi.html as is the
> example with array literal/square bracket property accessor.
>
> https://mail.mozilla.org/htdig/es-discuss/2010-July/011600.html
You are not demonstrating what you seem to think you're demonstrating.
>> So any statement of the form "... ASI changes program behavior WRT
>> unrestricted productions is bigger problem" is simply misstated.
>>
> See above.
No, you're not demonstrating a change of program behavior due to ASI on the
result of the concatenation. You are showing a change of behavior due to
concatenation relieving an error that ASI corrects in the case where a.js is
not the first part of a concatenation where b.js follows.
>> Again, it is the expectation of newline significance where none exists,
>> where no error is corrected by ASI, that leads people astray. This is worth
>> working to fix, or mitigate, provided migration works well.
>>
> I don't understand what you mean.
See above. People read
var MyWidget = function(){
this.name = "mike";
}
(function() {
/*...*/
});
and think the newline after the } on its own line (line 3 above) terminates the
var statement. It's an easy mistake to make given how similar code where the
next line does not begin with (, [, +, etc. works. Especially if the next line
begins with a keyword.
/be_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss