[stdlib] Rename char_length to count_codepoints for consistency#5764
[stdlib] Rename char_length to count_codepoints for consistency#5764martinvuyk wants to merge 1 commit into
char_length to count_codepoints for consistency#5764Conversation
|
Thanks for this Martin! :) While we're in the area, what do we think about naming this I think |
@ConnorGray I think that is an interesting idea. I was thinking of length more to keep in line with the |
|
Hi Martin, you have a point. I like E.g. looking at: for i in str.count_codepoints():
...vs for i in str.codepoints_count():
...Of course, perhaps we might ultimately end up with something like I suppose I don't have a strong opinion between Perhaps @NathanSWard and/or @barcharcraz have thoughts? |
This is probably a fair point. Though, if they're unfamiliar with Unicode / UTF-8, I think they're better served if our API's nudge them towards learning about those? 🙂 If they reach for an "easy" sounding name like |
Yeah that's why I was thinking of maybe deprecating
We can already do Something that would solve many of the "people won't go and read builtin method's docstrings for each type would be solved by having the compiler allow something like @always_inline
fn len[T: Sized](value: T) -> Int:
__doc__ = T.__len__.__doc__
return value.__len__() |
|
Hey Martin, just chatted with some folks on the team. I think we're +1 to trying out deprecating I like your idea about how to share docstrings between methods. That's definitely a problem we need to solve. I'm not sure of the best design. I could also see something like a |
|
Regarding needing to pick some name, I suggest we go with |
a8165d5 to
7c6ab27
Compare
char_length to codepoint_length for consistencychar_length to count_codepoints for consistency
…ngLiteral Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
7c6ab27 to
2320cee
Compare
|
!sync |
barcharcraz
left a comment
There was a problem hiding this comment.
Thanks martin, this does seem like a better name.
Good catch to add it to StringLiteral as well
|
✅🟣 This contribution has been merged 🟣✅ Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the main branch during the next Mojo nightly release, typically within the next 24-48 hours. We use Copybara to merge external contributions, click here to learn more. |
|
Landed in 8cf841c! Thank you for your contribution 🎉 |
Rename
char_lengthtocount_codepointsfor consistency and add the methods toStringandStringLiteral