On 4/19/11, Brendan Eich <bren...@mozilla.com> wrote:
> On Apr 19, 2011, at 8:39 AM, Isaac Schlueter wrote:
>
>> This style is more easily
>> scanned.  The important tokens are along the left edge, which forms a
>> straight line with logical and orderly breaks, and those tokens are
>> not overused, so their presence or absence is very noticeable.  The
>> right-edge is jagged, and when every line has a ";", the brain tends
>> to filter out their presence, making it hard to notice their absence.
>
> This is accurate in my experience. Even experienced semicolon users
> sometimes leave a few out, and the lack is hard to see.
>
>
>>> Restricted productions are the most benign cases. How ASI changes
>>> program behavior WRT unrestricted productions is bigger problem.
>>
>> Can you provide examples of the sort of unrestricted productions
>> you're referring to, where unexpected "semicolon insertion" changes
>> program behavior?  In my experience, it is the *lack* of ASI that
>> usually causes problems with unrestricted productions.
>
> Must be what Garrett means, since ASI is *only* error correction, plus of
> course built-into-the-grammar restricted productions.
>
> So ASI does *not* change program behavior from non-error behavior A to
> non-error behavior B. It instead suppresses early SyntaxError with
> successful evaluation, in a deterministic way.
>
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?

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";
}

Now concatenate a.js and b.js and you have:
var MyWidget = function(){
 this.name = "mike";
}(function() {});

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.

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

> So any statement of the form "... ASI changes program behavior WRT
> unrestricted productions is bigger problem" is simply misstated.
>
See above.

> 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.
-- 
Garrett
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to