Question about allowed characters in identifier names

Mathias Bynens mathias at qiwi.be
Sat Aug 24 14:19:54 PDT 2013


On 24 Aug 2013, at 22:13, Norbert Lindenberg <ecmascript at lindenbergsoftware.com> wrote:

> On Aug 24, 2013, at 2:02 , Mathias Bynens <mathias at qiwi.be> wrote:
> 
>> On 27 Feb 2012, at 22:58, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
> 
>>> var \ud87e\udc00 would probably still be illegal because each \uXXXX define a separate character but: var \u{2f800} =42; schould be find as should the direct none escaped occurrence of that characters.
>> 
>> Wouldn’t this be confusing, though?
>> 
>>   global['\u{2F800}'] = 42; // would work (compatible with ES5 behavior)
>>   global['\uD87E\uDC00'] = 42; // would work, too, since `'\uD87E\uDC00' == '\u{2F800}'` (compatible with ES5 behavior)
>>   var \uD87E\uDC00 = 42; // would fail (compatible with ES5 behavior)
>>   var \u{2F800} = 42; // would work (as per your comment; incompatible with ES5 behavior)
>>   var 丽 = 42; // would work (as per your comment; incompatible with ES5 behavior)
> 
> I do think it's confusing that \uD87E\uDC00 is not allowed in the current ES6 spec, and have reported this as part 4 of
> https://bugs.ecmascript.org/show_bug.cgi?id=501

Agreed. It would make much more sense to just treat `\u{2F800}` and `\uD87E\uDC00` exactly the same way, even outside of string contexts.

> The issue was also discussed, without a conclusion, at the TC 39 meeting in July 2012 - look for "# Unicode support":
> https://mail.mozilla.org/pipermail/es-discuss/2012-July/024207.html
> 
>> Using astral symbols in identifiers would be backwards incompatible, even if the raw (unescaped) symbol is used. There’d be no way to use such an identifier in an ES5 environment. Is this a problem?
> 
> It's the same problem as when using
>    let a = 42;
> 
> You should not expect that a program using new ES6 features will run on ES5 implementations (although it might run on some that have already added the ES6 features used).

I just want to make sure it’s possible to write a polyfill (in ES5) for the `String.isIdentifier{Start,Part}` strawman. As long as `String.isIdentifierStart('\uD87E\uDC00')` and `String.isIdentifierStart('\u{2F800}')` are expected to return different results (as Allen suggests), this is impossible.


More information about the es-discuss mailing list