RegExps that don't modify global state?

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Sep 23 07:37:23 PDT 2014


specially when you `yield` around, who knows what happens ... but yes, this
looks like the best option to me too so +1

On Tue, Sep 23, 2014 at 3:35 PM, C. Scott Ananian <ecmascript at cscott.net>
wrote:

> On Tue, Sep 23, 2014 at 10:04 AM, Claude Pache <claude.pache at gmail.com>
> wrote:
> > Another idea is to  to define a variant of the `RegExp.prototype.exec()`
> method, that does the Right Thing (doesn't read/write stuff on the RegExp
> instance, nor on the RegExp global, nor I don't know where):
> >
> >     RegExp.prototype.run (str, params):
> >
> >         Do what is currently specified for `RegExp.prototype.exec`,
> except that:
> >
> >             * global, sticky and lastIndex properties are read and
> written on `params` instead of `this`
> >             * implementations are not allowed to extend that method in
> order to mess with `RegExp`, etc.
> >
> > All other (legacy) methods are rewritten in terms of `RE.p.run` (in the
> current ES6 draft, they are mostly written in terms of `RE.p.exec`).
>
> +1.  Deprecating the side-effects of the legacy methods might be tricky
> though.
>   --scott
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140923/a2dff67e/attachment.html>


More information about the es-discuss mailing list