On Jun 24, 2008, at 5:46 PM, Allen Wirfs-Brock wrote:
I’ve taken a crack at cleaning up Pratap’s initial specification for
supporting direct indexing of strings, eg “abc”[1] yields “b”
Here are the semantics that seemed to make sense:
s[n]
1) If s has an own property whose name is the same as the value of
n, the value of that property is returned.
Since s is a string value, not an object, then it cannot have any own
properties. The autogenerated wrapper for s does have some own
propertied.
2) else If the value of n is convertible to a number that is within
the bounds of the string value, return a string containing the
corresponding character
3) else if try to resolve n as the name of an inherited property
4) else return undefined.
In other words, indexing into a string with a “valid” index returns
that appropriate character unless somebody has explicitly defined a
property named by that index on the object.
It is not possible to define a custom property on a string value. On a
string object you could.
I would suggest it makes more sense to make index properties of a
string act like index properties of an array, but read-only.
Regards,
Maciej
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss