On Jun 27, 2008, at 6:51 AM, Pratap Lakshman (VJ#SDK) wrote:

> The side effect is as follows: if “this” does not have a “length”  
> property, it ends up getting one; if “this” does have a length  
> property, but is not an Array, that “length” property will get  
> updated.

True, and not just for pop -- for all generic Array methods that  
mutate length.

> What is the rationale for this?

I don't recall a detailed rationale on this point, but the pseudo- 
code is simplest without a special case that avoids creating a  
'length' property if one does not exist, and it's easy to rationalize  
"caveat hacker" -- if you wrote Array.prototype.pop.call(p), you  
wanted to have effects on your pizza ;-). The simpler specs are a  
good thing.

Trying to change this now seems dicey. We don't know if any web  
scripts count on this edge case. Creating length may be a requirement  
because lazy pizza coders left 'length' out, knowing it would be  
created, and then depended on it becoming 0 (e.g., in a < expression  
-- if undefined it would become NaN and the condition would be false).

There does not seem to be any profit in taking risk by changing the  
semantics.

/be
_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to