-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "Deprecate ismatch(r, s) in favor of contains(s, r)" #26211
Conversation
This reverts commit 6ca43fc.
I'm not strongly opposed, but I think this needs more arguments than "I don't like it". ;-) In particular, why do we need a special function for regular expressions here, but in |
It's kind of semantically weird to say that a string "contains" a pattern. It contains a substring which matches that pattern, but it doesn't contain the pattern. I agree that this feels really awkward every time I use it, both for the linguistics of it and for the argument order which is annoying too. |
a smattering of what other languages do for the contains c++ c# clojure coffeescript D Erlang F# java javascript kotlin lua python ruby rust scala swift ismatch c++ C# clojure D Erlang go java javascript lua nim perl 6 python swift |
and having looked over all those, what if we had: find(str1::String, str2::String)
find(str::String, re::Regex) ? |
We already have |
Our |
if I understand all the find* business correctly, we actually have no methods of |
Whaa? Y'all are fickle. I still think Another possible name is |
what about |
Likewise. I read the |
I like |
I also think there is a genericness argument here. Should you have to change function name just because you've expanded what you're searching for from a single string to a regex? |
Nobody's arguing for taking away the ability to write |
Suggestion from triage. Since
predicate, that would then work for regexes. |
That would work for this case nicely: |
Should probably be |
It's occurred to me that Slight wrinkle: a mathematical subsequence is generally not required to be contiguous. Do we care? |
I'd argue no; while more often than not we're precise in our mathematical details and terminology, I think in this case it's not really problematic, as this isn't really a mathematical function. We can simply document that the given subsequence should be contiguous. |
Writing it down here, because it came up during triage, but probably not directly related. If we wanted to be clearer in separating out searching for subsequences, we could have a
would be consistent. |
General triage consensus is that we should go with |
This reverts commit 6ca43fc.
Fixes(?) #25584
Every time I have changed code from
ismatch(r, s)
tocontains(s, r)
it feels a bit odd.