Skip to content

Fix Issue 17525 - std.algorithm.searching.skipOver should have a single argument with pred version#5543

Merged
dlang-bot merged 1 commit intodlang:masterfrom
RazvanN7:Issue_17525
Jul 7, 2017
Merged

Fix Issue 17525 - std.algorithm.searching.skipOver should have a single argument with pred version#5543
dlang-bot merged 1 commit intodlang:masterfrom
RazvanN7:Issue_17525

Conversation

@RazvanN7
Copy link
Collaborator

@RazvanN7 RazvanN7 commented Jul 5, 2017

No description provided.

@dlang-bot
Copy link
Contributor

dlang-bot commented Jul 5, 2017

Thanks for your pull request, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some tips to help speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

Bugzilla references

Fix Bugzilla Description
17525 std.algorithm.searching.skipOver should have a single argument with pred version

@RazvanN7
Copy link
Collaborator Author

RazvanN7 commented Jul 5, 2017

Any ideas on why circleci is failing? The line that is reported doesn't even call empty

@wilzbach
Copy link
Contributor

wilzbach commented Jul 5, 2017

#5497

auto s4 = "\t\t\t";
assert(s2.skipOver!isWhite && s2 == "value");
assert(!s3.skipOver!isWhite);
assert(s4.skipOver!isWhite && s3.empty);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to import empty from std.range.primitives here (public tests need to be runnable standalone)

@RazvanN7
Copy link
Collaborator Author

RazvanN7 commented Jul 5, 2017

@wilzbach Ah, didn't see that one. Thanks anyway.

@wilzbach
Copy link
Contributor

wilzbach commented Jul 5, 2017

Ah, didn't see that one

As this is now the second PR in a row, you should start a NG thread to remind people to tag their PRs. In theory the bot could do this as well (I don't recall why it doesn't, feel free to open an issue)

@RazvanN7
Copy link
Collaborator Author

RazvanN7 commented Jul 5, 2017

@wilzbach should I keep this PR open or should I close it and review @JackStouffer 's ?

@wilzbach
Copy link
Contributor

wilzbach commented Jul 5, 2017

@wilzbach should I keep this PR open or should I close it and review @JackStouffer 's ?

As the other PR has a rather long discussion, I would first read through it and try to find out the consensus. IIRC there wasn't none yet. Once there is an agreement, you can always reopen this PR if necessary (or create a new one from the same branch). Sounds good?

@wilzbach
Copy link
Contributor

wilzbach commented Jul 5, 2017

Next time please add "Fix Issue $Number" so that the dlang bot can associate your PR with the bug fix.

Btw do you see the on the bug list summary? It means the issue is just "mentioned" and won't be automatically closed.
I have opened a PR to clarify this -> dlang/dlang-bot#124

@RazvanN7 RazvanN7 changed the title Issue 17525 - std.algorithm.searching.skipOver should have a single argument with pred version Fix Issue 17525 - std.algorithm.searching.skipOver should have a single argument with pred version Jul 5, 2017
@RazvanN7
Copy link
Collaborator Author

RazvanN7 commented Jul 5, 2017

@wilzbach Oh I get it now. I didn't thought at all what that tiny x means. I rebased and added the proper name. Thanks for all the enlightening comments!

Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, please mind @wilzbach 's review and then let's get this in. Thanks!

@RazvanN7
Copy link
Collaborator Author

RazvanN7 commented Jul 7, 2017

@andralex it's there: https://github.com/dlang/phobos/pull/5543/files#diff-8b73351c2fbfb7fef513b00ced46d022R3989 , but I amended the commit so that there is no need to squash

@dlang-bot dlang-bot merged commit 37d15a8 into dlang:master Jul 7, 2017
@CyberShadow
Copy link
Member

Err, I'm certain I must have pointed out somewhere (not this thread I guess) that this implementation is inconsistent with the other skipOver overloads. This one loops, whereas the others don't.

@andralex Does this make sense to you?

@RazvanN7
Copy link
Collaborator Author

RazvanN7 commented Jul 7, 2017

@CyberShadow
Copy link
Member

That loop simply consumes the two input ranges for comparison; it does not consume multiple instances of the "prefix". Consider the difference between s.skipOver(' ') and s.skipOver!(c => c == ' ') - intuitively one may think that these should behave the same, but they don't!

@RazvanN7
Copy link
Collaborator Author

RazvanN7 commented Jul 7, 2017

@CyberShadow As I see it, there are 2 classes of skipOver methods: those that skip over multiple range elements and those that skip over the first element. This PR enhances the first category.

The 2 cases you are taking about are likely to appear in the real world and skipOver should manage them both. I don't see any inconsistency here.

@andralex
Copy link
Member

andralex commented Jul 7, 2017

@CyberShadow it's a point, but the usefulness in parsing is there.

  • s.skipOver(' ') ---> "skip over one space"
  • s.skipOver(c => c == ' ') ---> "skip over any number of spaces"
  • s.skipOver(c => c.among(' ', '\t', '\r', '\n') ----> "skip all whitespace"

@CyberShadow
Copy link
Member

It would be less confusing if there was a different overload set for functions that skip over multiple instances of the pattern.

@CyberShadow
Copy link
Member

CyberShadow commented Jul 7, 2017

skipOver:

  • s.skipOver(' ') ---> "skip over one space"
  • s.skipOver(c => c.among(' ', '\t', '\r', '\n') ----> "skip over one whitespace character"

skipWhile:

  • s.skipWhile(' ') ---> "skip over spaces"
  • s.skipWhile(c => c.among(' ', '\t', '\r', '\n') ----> "skip all whitespace"

The return types should be different. The version that skips multiple prefixes ought to return a size_t.

@andralex
Copy link
Member

andralex commented Jul 7, 2017

@CyberShadow that's awfully nice, @RazvanN7 how about implementing that real quick?

@CyberShadow
Copy link
Member

@andralex @RazvanN7 Found the previous discussion: #5497 (comment)

Looks like we already have some primitives in Phobos to do some of these things. CC @wilzbach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants