>>> var foo\u005B\u005D = 'bar';
>>>
[quoted text clipped - 8 lines]
> But it doesn't work at all well. ECMA 262 is unclear as to how that
> should be handled,
IBTD, I think it is pretty clear about that.
> but the implication of what it does have to say about
> UnicodeEscapeSequences is that the above should be a syntax error,
True. The implication of
| Unicode escape sequences are [...] permitted in identifiers, where they
^^^^^^^^^^^^^^
| contribute a single character to the identifier, as computed by the CV
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| of the UnicodeEscapeSequence (see section 7.8.4). The \ preceding the
| UnicodeEscapeSequence does not contribute a character to the identifier.
is that the above should be equivalent to
this["foo[]"] = 'bar';
where the left hand side of the AssignmentExpression should be parsed as
_one identifier_, at least the leading `this[' and the trailing `]' as
two identifiers, _not_ the property accessor syntax:
The \UnicodeEscapeSequence is allowed only in Identifiers and StringLiterals
(the Unicode escape sequence in RegularExpressionLiterals is produced by
`\NonTerminator', not `\UnicodeEscapeSequence'); since this is obviously
no string literal, it must be an identifier.
But `[' and `]' are not allowed in Identifiers, not even per evaluated
\UnicodeEscapeSequence --
| A UnicodeEscapeSequence cannot be used to put a character into an
| identifier that would otherwise be illegal.
-- (or at least `Identifier StringLiteral Identifier = StringLiteral;'
cannot be produced by AssignmentExpression), so theoretically this is a
SyntaxError anyway.
However, ECMAScript allows a conforming implementation "to support program
[...] syntax not described in this specification." ISTM that this
provision resets all arguments about how a conforming implementation MUST
be, as argued here, to how it CAN be, perhaps SHOULD be.
> and it is in IE and Opera. There is enough ambiguity in the specification
> to allow Mozilla to treat the escape sequences as square brackets and so
> operators but there are good reasons for expecting the syntax errors
> reported by other browsers.
Yes, but I do not credit that to the specification's ambiguity.
> Javascript certainly cannot convert UnicodeEscapeSequences in its
> source code into their corresponding CVs prior to tokenisation without
> violating the specification with regard to end-of-line comments, regular
> expression and string literals
Yes it can :)
> (i.e. for example, /u000A may not be
\u000A
> treated as a LineTerminator (ECMA 262, 3rd edition; Section 7.3) in an
> end-of-line comment or a regular expression or string literal).
True, there are limitations set by ECMAScript where \UnicodeEscapeSequence
may be used. However, by the Conformance section (e.g. ES3, section 2), a
conforming implementation is allowed to support even that. See above.
So the bottom line is instead that there is an ECMAScript implementation
that supports the suggested syntax for creating property access syntax:
JavaScript. However, as we know that there are also widely distributed
ECMAScript implementations that do not support it (JScript, the Opera
implementation), it is unwise to make use of it.
PointedEars