Rationalizing ASI (was: simple shorter function syntax)
Brendan Eich
brendan at mozilla.com
Sat Jul 24 23:46:16 PDT 2010
On Jul 24, 2010, at 11:30 PM, Mark S. Miller wrote:
> From: Brendan Eich <brendan at mozilla.com>
> I see three tenable alternatives:
>
> A. Remove ASI in some opt-in version, in full -- no error correction, no restricted productions.
>
> This seems best to me. I would have no objection to keeping the second bullet of ASI rule #1. I may even advocate keeping it; I'm not sure yet. However, the first bullet of rule #1 is a terrible hazard.
Can you say more? It's hazardous because "X, Y, and Z" -- three concrete examples.
The hazard I see, which Garrett Smith mailed me about just now, is the one I already identified as "the mistaken expectation of ASI" -- the case where there's no syntax error for ASI to correct:
var MyWidget = function(){
this.name = "mike";
}
/**
* Initialize Widget
*/
(function() {
/*...*/
});
(from http://jibbering.com/faq/notes/code-guidelines/asi.html).
This is simply a failure to use a semicolon where it is needed.
Removing ASI won't make this hazard go away unless (eventually, and in statistically significant numbers) developers stop "counting" on such magical "DWIM" ASI, and become more careful. But that is farfetched, since it's pretty easy to make this mistake even if one assiduously inserts semicolons manually.
> Yes! Data! Bring it on!
That's your job :-P. I don't have access to the Google copy of the web, or sawzall.
/be
More information about the es-discuss
mailing list