Subj : Re: Array and [ ] To : netscape.public.mozilla.jseng From : =?ISO-8859-1?Q?Georg_Maa=DF?= Date : Sun Jan 23 2005 07:44 pm Brendan Eich wrote: > Personally I prefer the current SpiderMonkey way, > and if you want to be able to change Array (as shown in your previous > post, to lowercase string elements added to instances, e.g. -- although > a subclass of Array might be more appropriate in a real application), > more power to you. Doing it with a subclass is more obvious that it is different to the original, but when I modell the languae it self by modelling it's core objects and functions, I typically want this to be completely transparent and in this case [] and new Array must me equivalent as it is in SpiderMonkey, otherwise users could accidently circumvent the manipulation by using []. An I'm such a user mainly using []; What I don't see for the moment is a way how to use the original implementation inside the manipulated Array function, without storing a public reference being accessable also from outside. With a closure we could hide stuff declared inside from the outside. But here it is not declared inside but must be copied by reference from outside to inside, where it does not reside permanently because we do not have static variables, or where we have them they are accessable from outside. > But if you want Array to be mutable, then I think you should want [] to > be short-hand for new Array. I allways write [1] not new Array(1), because new Array(1) is ambiguous and does in the most implementations (including the ECMA spec) not the same as new Array (1,2). I normally use Array only for prototyping or in combination with apply. For all Arrays with known number of items, I always use the literal. Greetings, Georg -- Georg Maaß - bioshop.de D-76227 Karlsruhe, Westmarkstraße 82 HTML, XML / JavaScript, C++, Java, PHP, VB / CGI, JSP, ASP, ASP.net - The ultimate DHTML engine: http://gml-modul.sourceforge.net - http://sourceforge.net/projects/gml-modul .