Letting RegExp method return something iterable?

Brendan Eich brendan at mozilla.com
Thu Aug 29 19:06:07 PDT 2013


Oliver Hunt wrote:
> I would favor ignoring lastIndex rather than throwing, but to be sure can you clarify what you mean by global regexp?

One created with the 'g' flag, either literally (/re/g) or via the 
constructor (new RegExp(src, 'g')).

> If we're talking /.../g, then my feeling is that the /g should be ignored -- if you're wanting a regexp iterator for a string (or whatever) I would think that the API would imply that all regexps were intended to be "global".

Agreed, if we don't just throw from execAll on a global regexp ;-).

> If we're talking about multiple concurrent iterators with the same regexp/string then it should definitely be ignored :D

IOW, in general, 'g' should be ignored by new APIs.

> Erm.
>
> I'm not sure if that's coherent, but the TLDR is that I favor ignoring all the old side state warts (i would not have iterators update the magic $ properties, etc)

Yes, agreed. The devil is in the details.

/be


More information about the es-discuss mailing list