You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fact that $\&, $\+, $\`, and $\' are not valid IdentifierNames not only makes it awkward to access the property (you have to use e.g. RegExp["$&"]) but also conflicts with Function.prototype.toString()'s implied requirement that [[InitialName]] is a valid PropertyName:
If func is a built-in function object, return an implementation-defined String source code representation of func. The representation must have the syntax of a NativeFunction. Additionally, if func has an [[InitialName]] internal slot and func.[[InitialName]] is a String, the portion of the returned String that would be matched by NativeFunctionAccessoropt PropertyName must be the value of func.[[InitialName]].
How should this be handled?
An elegant way out would probably be to accept the suggestion in #17 and just reuse the functions named lastMatch, lastParen, leftContext, and rightContext, respectively.
The text was updated successfully, but these errors were encountered:
Right. It's not pretty but this would work, albeit only with some additional spec text (in SetFunctionName presumably) that ensures [[InitialName]] is changed to ["$&"] (...) for these functions.
I’d think LiteralPropertyName : StringLiteral might be preferred over ComputedPropertyName for representing these names. Like for the following, just with [native code] included between the braces:
OTOH, I’m not sure I’d be able to articulate a real rationale for this preference. It seems like using ComputedProperty is “extra complexity” — an “arbitrary” AssignmentExpression where a “static” StringLiteral could have been used instead? Given it is just a representation either way though and not code, I realize this impression of avoidable complexity is really an illusion.
The fact that
$\&, $\+, $\`, and $\'
are not valid IdentifierNames not only makes it awkward to access the property (you have to use e.g.RegExp["$&"]
) but also conflicts with Function.prototype.toString()'s implied requirement that [[InitialName]] is a valid PropertyName:How should this be handled?
An elegant way out would probably be to accept the suggestion in #17 and just reuse the functions named
lastMatch
,lastParen
,leftContext
, andrightContext
, respectively.The text was updated successfully, but these errors were encountered: