Negative indices for arrays
Allen.Wirfs-Brock at microsoft.com
Thu Nov 11 14:17:39 PST 2010
> -----Original Message-----
> From: Dmitry A. Soshnikov [mailto:dmitry.soshnikov at gmail.com]
> Yeah, it's possible to make this thing generic, though maybe also good only for
> arrays. Need to more discuss, think.
There isn't actually all that much difference between array instances and non-array objects with array index properties. ES5 went in the direction of making sure that array functions all worked on arbitrary objects. I don't think we would want to go backwards on that.
> > this would break any code that currently uses property names like "-1".
> I repeat, we tried to find and remind at least _one_ more-less serious use-case
> where negaitve indices where used in the old code with array -- and can't. Do
> you know any? It will be useful if you show.
Anybody who is using an object (possibly an array instance) as a hash table with signed integer keys
> > This isn't just syntactic sugar. It also has all sorts of complications relating to
> the basic property access semantics. Getting this right would probably require a
> major redesign of ECMAScript object/property semantics in a manner that I
> wouldn't anticipate happening anytime soon.
> Thanks. Though, I don't see a bit changes (how you like to described all in dark
> colors :)). At maximum (if not generic) -- only [[Get]] of arrays and strings will be
And presumably [[Put]] and as some sort of dynamic parsing of string property names and for generic object support check for a length property, etc.
> So, do I understand correctly that you are against this feature and don't like it?
> (Just another question -- are you aware that it used in Python, Ruby, Perl,
> Coffee, other langs?)
More information about the es-discuss