delegating to typed objects

Brendan Eich brendan at
Mon Jul 9 17:00:40 PDT 2007

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  

> 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.



More information about the Es4-discuss mailing list