On 4/19/11, Isaac Schlueter <[email protected]> wrote:
> On Tue, Apr 19, 2011 at 11:02, Garrett Smith <[email protected]> wrote:
>> On 4/19/11, Brendan Eich <[email protected]> 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?
>
> They depend on the preceding token, *and* they cause a preceding \n to
> be elided. That is the problem with JavaScript's statement
> termination rules with respect to lines that start with +, /, *, -, (,
> or [.
>
>> Now concatenate a.js and b.js and you have:
>> var MyWidget = function(){
>> this.name = "mike";
>> }(function() {});
>
> That error isn't caused by ASI. Disabling ASI won't prevent that error.
>
> That error is caused by the lack of ASI. It's caused by the \n being
> elided when the next line starts with a (.
>
>>> So any statement of the form "... ASI changes program behavior WRT
>>> unrestricted productions is bigger problem" is simply misstated.
>>>
>> See above.
>
> ASI didn't change the program behavior. ASI didn't happen in that example.
>
> Newline elision changed the program behavior.
No, `MyWidget = function(){}` was not explicitly terminated by a
semicolon. The end of the input stream is reached and a semicolon is
inserted.
"Newline elision" did not change behavior.
Concatenation of a.js and b.js results in behavior that is not the
same as when a.js and b.js are in separate files.
In a.js, there was a missing semicolon after the FunctionExpression.
On its own, a.js does what was wanted of it.
File b.js contains what the author wanted as a grouping operator and
it works fine as b.js alone. But concatenating a.js + b.js to one
file, the result is different behavior. That's a problem.
The changed behavior problem is avoidable, by beginning files with `;`
(as already mentioned in this thread). Dojo.js does that, for example,
to avoid the problem of changed behavior when runing through
shrinksafe or yuicompressor (both of which concatenate and minify)
thus avoiding the potential for different program behavior.
--
Garrett
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss