-
Notifications
You must be signed in to change notification settings - Fork 12
Naming discussion #26
Comments
The committee seemed to be strongly against setting the |
The word "all" means "all matches you'd get if you looped over the string"; which is the only "all" anyone's ever really wanted or gotten in userland that I'm aware of. What behavior would you expect "matchAll" to provide? |
I have a different impression - what you're describing above sounds to me like The major differences between |
match with a global regex doesn't provide what I need; which is the capturing groups. The goal of matchAll is to provide nested capturing groups in the match object; as What name do you suggest? |
I realize that, I was just saying that your description above ("all matches you'd get if you looped over the string") sounds to me like a simple global
I'm not advocating for a particular name, I just feel that
The overload between FP and the parsing world already exists so that seems ok to me. What I like about this one is the consistency with at least 1 other language. I agree that it's not a very descriptive name though. Looking at other languages: In C#, Regex.Matches seems very similar. I like this name, but it's very similar to It's worth noting that pcre: preg_match_all is a global version of |
"matches" also sounds like it's a predicate. As for preg_*, those don't take flagged regexes, they take strings, so I'm not sure that's a relevant comparison. |
Friendly ping, does anyone else have opinions? I chatted about this with Brian (+cc @bterlson) and I think the gist was:
|
Committee consensus remains that the name should be |
I know I'm late to the party, but I wanted to raise this point as well since
matchAll
is highly unintuitive or even misleading to me.matchAll
suggests a variant ofmatch
that returns all matches, or possibly something related to global/nonglobal semantics. People seem to already fall into this kind of thinking as the discussions about the number of results produced by"ababa".matchAll(/aba/g)
shows.Correct me if I'm wrong, but the actual semantics are 'like
match
, but returns an iterator of result objects'. It's a pretty big mental leap to associate the 'all' inmatchAll
with 'complete result objects'.I don't have suggestions for a better name myself. But FWIW I think both
scan
andmatchIterator
, as brought up at the September meeting, are both preferable tomatchAll
.cc @mathiasbynens
The text was updated successfully, but these errors were encountered: