On May 16, 2010, at 7:18 PM, David Herman wrote:
RegExp literal expressions evaluate to mutable object values, per
ES5 and reality (ES3 got this wrong, making an object per literal
lexeme -- not per evaluated expression).
Yes, but there's no reason to assume a RegExp token would be a
RegExp literal expression.
The reader of the source might assume exactly that. One regexp looks
like another, and might be expected to quack like any other.
Modules are static. Do we really want to drag in some of the
runtime (RegExps) just to filter imports? This seems not only like
over-design, but also the wrong design.
Import/export declarations are distinguished contexts; there's no
need to introduce runtime evaluation. A sensible design for import/
export declaration with a RegExp would simply be run a regular
expression at compile time, with no ES object creation involved.
That's possible, and desirable in practice: regexps have effects in
real-world implementations (the unspecified but still used RegExp.$_,
RegExp.$1, etc. properties). If written with /y or /g they mutate
there own lastIndex property and use it for subsequent matches (how
many times is /.*\.js$/g evaluated in that import directive?).
I'm not advocating the feature, but if we did include it, ISTM the
benefit of using regexps is precisely their limited power.
You'd have to limit that power from what it is today in terms of
effects (including those pesky de-facto standard effects).
Another unwanted power is that these NFAs misnamed "regular
expressions" can blow up with O(exp(n)) complexity due to
backtracking. This is enough of a problem that we're about to try
throwing an exception when JS regexp exec complexity measured in terms
of active backtrack states compared to target string length seems to
be worse than O(n^3) (see https://bugzilla.mozilla.org/show_bug.cgi?id=452451
and bugs it cites).
Making some tamed, quasi-regexp-just-for-import seemed not what Kam
proposed, but anyway undesirable on its face. I mean, the taming
attempt is desirable ignoring the big picture, but the whole idea
seems misbegotten. My two cents.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss