RegExps that don't modify global state?

Allen Wirfs-Brock allen at
Tue Sep 16 11:35:22 PDT 2014

On Sep 16, 2014, at 11:16 AM, Domenic Denicola wrote:

> I had a conversation with Jaswanth at JSConf EU that revealed that RegExps cannot be used in parallel JS because they modify global state, i.e. `RegExp.$0` and friends.
> We were thinking it would be nice to find some way of getting rid of this wart. One idea would be to bundle the don't-modify-global-state behavior with the `/u` flag. Another would be to introduce a new flag to opt-out. The former is a bit more attractive since people will probably want to use `/u` all the time anyway. I imagine there might be other possibilities others can think of.
> I also noticed today that the static `RegExp` properties are not specced, which seems at odds with our new mandate to at least Annex B-ify the required-for-web-compat stuff.

Yes, they should be in Annex B.  But that means that somebody needs to write a spec. that defines their behavior.

We could then add that extension to clause 16.1 as being forbidden for RegExps created with the /u flag. 


More information about the es-discuss mailing list