-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Introduce skipuntil function and deprecate skipchars #36160
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
base: master
Are you sure you want to change the base?
Conversation
skipuntil is similar to skipchars but advances a stream until predicate returns true rather than until predicate returns false. This should be more discoverable and improve clarity.
Closes JuliaLang#36132 The name skipchars does not clearly communicate the functionality available. Tests for skipchars were left in place to ensure the @deprecate macro correctly converted those calls to using skipuntil. Although CI only runs tests with --depwarn=error, I have confirmed these tests pass successfully with --depwarn=yes/no locally.
|
@JeffBezanson, do you have any thoughts on API coherence here? |
|
Polite bump to request any feedback on whether this is worthwhile to deal with before 2.0 given the issues described in OP. |
|
Marking for discussion on the next triage call. |
|
I think it's helpful to separate readuntil and skipchars --- I don't know how intentional it was, but the different names are good because the functions are used in very different ways. |
|
We also now have |
|
Some notes from triage discussion:
@JeffBezanson feels that this function is fundamentally different from
Note that this change doesn't generalize |
|
I don't understand some of these comments and would appreciate any help resolving my confusion.
This pull-request does not generalize
I agree that both behaviors are desirable, but I don't think having separate functions for them makes for a desirable API. I think ideally both the
The change as currently proposed is merely for api consistency and discover-ability without changing functionality at all. The fact that
So is the overall conclusion here that this change isn't worthwhile for the mere sake of discoverability? Adding support for other types than On the alternative of making it an additional method of |
I was mistaken when I wrote that. You're right, of course, that the PR doesn't generalize to non-Char iteration. |
Closes #36132.
skipuntilillustrates the purpose of this function much more clearlythan
skipcharsand improves discoverability.My only concern with this change is that the
skipuntilname nowmirrors the
readuntilname without providing a similarinterface:
readuntilonly takes aChar/Int/Stringand findsthe first occurrence of that rather than having the full flexibility
of taking a predicate.
readuntilhas a signature ofreaduntil(io, searchedfor)ratherthan
readuntil(searchedfor, io).readuntilis inclusive rather than exclusive. It includes theobject being searched for and leaves the stream position after that
object whereas
skipuntilleaves the stream position before.Point 2 means that point 1 can't be easily addressed by adding a
predicate-accepting version of
readuntil(unless we're willing toforgo do-block notation). Should I add a keyword-argument to
skipcharsto toggle it between inclusive/exclusive to resolve point3?
This was originally part of #36158 and is broken out now since the change is separate. If both are to be merged, I'd like to update this PR to make use of the function introduced in #36158.