Oh crap. Good point, Matthew. I'm with Ray -- probably not worth it, given
this potential problem.

On Thu, Jul 2, 2009 at 5:36 PM, Ray Cromwell <[email protected]> wrote:

>
>
> On Thu, Jul 2, 2009 at 2:02 PM, <[email protected]> wrote:
>
>> There's a few corner cases in which this optimization may change the
>> meaning of code:
>>
>> 1.  Name scoping of builtins using locals/builtins:
>>
>> var Array = function() { this.toString = function() { return "bleh"; }
>> };
>> x = new Array()
>> alert(x);
>>
>
> Ugh, you're right. Trapping this would be kind of tricky. I suppose I could
> keep track of any vars in scope that shadow Array/Object. There's also the
> case where
> an insane person modifies the global Array ($wnd.Array = ...) Would be nice
> if it implicity invoked Array's prototype constructor.
>
>
>
>
>>
>> var x = { Array: function() { this.toString = function() { return
>> "bleh"; } } };
>> with (x) {
>>   y = new Array();
>> }
>> alert(y);
>
>
> This one is easy. GWT's Javascript parser does not support 'with'. It's
> banned.
>
>
>>
>> 2. Parameters to constructor:
>>
>> new Object(1) - "wraps" the object in the parameter so that it has a
>> different identity.  This shouldn't be modified.
>>
>> new Array(1,2,3) - wraps the parameters in a new array.  This is always
>> equivalent to [1,2,3] (with the exception of cases that fall under 1
>> above).
>>
>
> This case can be handled.
>
> Given the complexity of tracking variable shadowing vs the benefit this
> patch provides, I'm not sure it's worth it. For example, in Showcase,
> there's only a single call to new Array() in the entire output.
>
> -Ray
>
>
>>
>>
>>
>> http://gwt-code-reviews.appspot.com/47810
>>
>
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to