"abc"[1] Would presumably parse as:
MemberExpression [ Expression ]
Whose semantic are:
1. Evaluate MemberExpression.
2. Call GetValue(Result(1)).
3. Evaluate Expression.
4. Call GetValue(Result(3)).
5. Call ToObject(Result(2)).
6. Call ToString(Result(4)).
7. Return a value of type Reference whose base object is Result(5) and whose
property name is
Result(6).
Note that steps 1,2, and 5 amount to ToObject(GetValue("abc")).
GetValue("abc") yields "abc" so this is really just ToObject("abc"). 9.9 says
ToObject when applied to a s primitive string: "Create a new String object
whose [[value]] property is set to the value of the string.". That string
object becomes the base object of the resulting Reference. So the literal get
converted into an object that has a [[Get]]
From: Brendan Eich [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 24, 2008 7:34 PM
To: Allen Wirfs-Brock; Maciej Stachowiak
Cc: [EMAIL PROTECTED] x-discuss; Pratap Lakshman (VJ#SDK);
[email protected] es4-discuss
Subject: Re: Semantics of "indexed" string access
On Jun 24, 2008, at 6:39 PM, Allen Wirfs-Brock wrote:
Actually, the intent was to support "indexed" access to both string values and
string wrapper objects. I just didn't make it clear in the example. The case
analysis was intended to apply to both. My reading of section 11.2.1 is that a
string value is to be transformed into an object before any actual property
access semantics are applied. Am I wrong?
No, the primitive string type (called "String", confusingly, in ES1-3 when it
uses type names) is not an object. It has no internal methods such as [[Get]].
Specifying the indexed unit-string access semantic based on the wrapper String
(spelled as in the language) object seems ok. I noted a Result(4) that should
have been Result(6) in step 7, via private email to Allen (this type of error
is going to happen a lot; count on it).
/be
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss