Side-effects of some Array methods ...
Brendan Eich
brendan at mozilla.org
Fri Jun 27 15:04:06 PDT 2008
On Jun 27, 2008, at 2:07 PM, Garrett Smith wrote:
> A program that called pop() on an object w/no length would know right
> away if it failed.
Why do you say that?
js> function pizza(){}
js> pizza.prototype.pop = Array.prototype.pop
function pop() {
[native code]
}
js> p =new pizza
[object Object]
js> p.length
js> p.pop()
js> p.length
0
js> a = []
js> a.pop()
js>
> Now, in the hypothetical scenario, would some built-in algorithmic
> safety checks help fail faster? Checks for 1) hasOwnProperty and not
> readonly or 2) has a setter
Again, we don't know what failing faster (you mean throwing a new
error as an exception) would break. The shell session above shows how
fail-soft could leave scripts executing and even behaving well.
Throwing an exception that's not caught would rain on such scripts'
parades.
/be
More information about the Es4-discuss
mailing list