Hi,

About the bad old nonstandard RegExp functionalities:

* `RegExp.prototype.compile()` — currently in Annex B;
* `RegExp.$1`, `RegExp.leftContext`, etc. — currently unspecced.

Although we could probably not get rid of them for plain regexps, I think it is 
a good idea to disable them for proper subclasses of RegExp (e.g., `class 
MyRegExp extends RegExp {}`).

Basically, the reason is that these methods break encapsulation (they operate 
on the raw regexp), leading to potential bugs when using them. Moreover 
`RegExp.$1` and friends have the additional troublesome property of relying on 
a global state that could be unexpectedly modified. For concrete examples of 
what could go wrong, see the subclass-restriction-motivation.md subpage in the 
proposal linked below.

Here is a link to a possible specification for the regexp statics (RegExp.$1, 
...), that includes the disabling of bad legacy features for proper subclasses 
of RegExp (and for some edge-cases around cross-realm interactions):

     https://github.com/claudepache/es-regexp-legacy-static-properties 
<https://github.com/claudepache/es-regexp-legacy-static-properties>

What do you think? Are implementations willing to try?

—Claude

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to