From: es-discuss-boun...@mozilla.org [mailto:es-discuss-boun...@mozilla.org] On 
Behalf Of Dmitry A. Soshnikov
...

>Yes, I mentioned it myself several times (in articles and including several 
>topics in es-discuss). Yes, Python distinguish. Ruby too. But from your 
>position, ES already has some lacks then. E.g. Object.keys() -- what does it 
>mean? What kind of "keys" you have found here? Or maybe 
>`Object.getOwnPropertyNames()`?

Object.keys and Object.getOwnProertyNames are both precisely defined by ES5. 
keys returns the names of all non-enumerable own properties of an object.  
getOwnPropertyNames returns the names of all own properties.

For example look at the results of Object.keys(new String('abc')) and 
Object.getOwnPropertyNames(new String('abc')) on an ES5 conforming 
implementation.

...
>Still ES has concept of an "array index" (separating it from all other 
>properties), I think a "virtual array index" is also good.

Not really.  ES5 does not generally consider array elements or "array index" 
property names as separate or different from other properties or property 
names.  According to the ES5 spec. (15.4) "array index"  is a term used to talk 
about property names that conform to a specific requirement 
(ToString(ToUint32(name) ) === name and ToUint32(name) !==2^32-1). 

 Instances of the Array constructor has special semantics for defining and 
updating "array index" properties. In addition, some of Array.prototype 
functions that perform arithmetic on "array index" property names do it in a 
manner that ensures results are also "array index" names.  Other than that ES5 
doesn't define any special semantics for "array index" properties.  
Implementations are free to optimize how they store array index properties (and 
many implementations do) but they are also free to optimize the storage of any 
property as long as the optimization maintains the observable ES5 semantics.

[from a different message]
> ES5 brought special semantics for subscription of strings, i.e. "abc"[0] is 
> "a", maybe it worth to make another sugar for arrays too?
Actually, all that ES5 did was specify that String objects (not string values) 
have non-writable, non-configurable properties corresponding to the individual 
characters of the encapsulated string value.  "abc"[0] is really equivalent to 
(new String("abc"))[0]

>Btw, if yes, it will touch strings too.
Presumably, any object with a 'length' property. 

As Oliver said, this would break any code that currently uses property names 
like "-1".  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.

Allen




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

Reply via email to