On Jul 9, 2007, at 4:51 PM, Kris Zyp wrote:

> You are right, it doesn't work for a Date, but it does work on an  
> Array.

Only if you don't call toString or toLocaleString.

Most Array and String prototype methods are intentionally generic.  
Too bad we didn't generalize this all over the place in 1996 (sorry,  
Tucker). To call such methods on other types of objects, in ES1-3 you  
have to use .apply or .call -- in ES4 there are Array.slice, .e.g.,  
counterparts that take a leading explicit this-object parameter for  
Array.prototype.slice.

> The incompatibility of calling setTime on the Date instance seems  
> to have more to do with the natural inclination to make primitives  
> classes "final" (I am not sure if they are in ES4, but in Java they  
> are final) than class method binding. While I am still hoping for  
> option 1, I will say that throwing an (incompatible object) error  
> on f.m() seems more consistent than the other possibilites that I  
> have been countering: non-shallow assignments, automatic this- 
> binding, or preventing the assignment of prototype objects that  
> happen to be instances of user defined classes.

Yeah.

/be


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

Reply via email to