Skip to content
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

Added a new popGrapheme function to std.uni #9053

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dukc
Copy link
Contributor

@dukc dukc commented Sep 20, 2024

Since it's Hackathon today, even if I'm not there I decided to do something in similar spirit.

@atilaneves new symbol canditate for phobos, meaning it needs your approval!

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @dukc! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#9053"

@dukc
Copy link
Contributor Author

dukc commented Sep 24, 2024

ping @atilaneves

The new function is a cross between the existing $(REF graphemeStride, std,
uni) and $(REF decodeGrapheme, std, uni) functions. The new function both
supports `@safe pure nothrow @nogc` like `graphemeStride` does as long as you
don't rely on autodecoding (side node: `@nogc` support for `graphemeStride`
Copy link
Contributor

Choose a reason for hiding this comment

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

This side note sounds like it should be its own PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is. I felt an added @nogc compability to an existing funtion alone wasn't worth a changelog entry so didn't add one in that PR. But since I'm writing here that graphemeStride is @nogc anyway, which until very recently wasn't the case, I feel it's useful to mention it. As in: "this note applies only with the latest compiler/Phobos".

@atilaneves
Copy link
Contributor

I don't know how useful this is so I would like someone that knows/cares about unicode more than me opines. Not sure who. @rikkimax ?

@rikkimax
Copy link
Contributor

rikkimax commented Oct 1, 2024

I don't know how useful this is so I would like someone that knows/cares about unicode more than me opines. Not sure who. @rikkimax ?

It allows you to get the grapheme length extracted, so you can slice and dice your string without allocation.

Kinda like graphemeStride except it pops it from the input like parse does.

It is one of those things that if a unicode library is being used you'll end up having a hundred variations of. I see nothing wrong with wanting functions like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants