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

better documentation for string reversal #23793

Merged
merged 3 commits into from
Sep 21, 2017
Merged

Conversation

stevengj
Copy link
Member

In looking back at #6165 (due to #23612), I realized that we never clearly documented the behavior or rationale.

In looking back at #6165 (due to #23612), I realized that we never clearly documented the behavior or rationale.
@stevengj stevengj added docs This change adds or pertains to documentation strings "Strings!" labels Sep 20, 2017
"êxa"

julia> join(reverse(collect(graphemes("ax̂e")))) # reverses graphemes
"ex̂a"
Copy link
Member Author

@stevengj stevengj Sep 20, 2017

Choose a reason for hiding this comment

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

The hat is shown in the wrong place in github's diff display in by browser, but if I paste it into my terminal it is correct. Apparently their display of combining characters is broken?

github:
image

copy/paste from github into a Julia session in a terminal:
image

copy/paste from github into Atom:
image

regex (regular expression) searches. See also [`reverseind`](@ref) to convert indices
in `s` to indices in `reverse(s)` and vice-versa, and [`graphemes`](@ref)
to operate on user-visible "characters" (graphemes) rather than codepoints
(which is more [visually pleasing but less useful](https://github.com/JuliaLang/julia/issues/6165) for reverse searching).
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't refer to GitHub issues in the official docs. Anyway people are unlikely to use graphemes unless they have a reason to, given that it's easier to iterate over/reverse codepoints.

@@ -117,10 +117,23 @@ end

Reverses a string.

Technically, this function reverses the "codepoints" in a string, and its
main utility is for reversed-order string processing, especially for reversed
regex (regular expression) searches. See also [`reverseind`](@ref) to convert indices
Copy link
Member

Choose a reason for hiding this comment

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

Just "regular expression"? Also, which use quotes around "codepoints"?

@@ -131,7 +144,7 @@ reverse(s::RevString) = s.string
"""
reverseind(v, i)

Given an index `i` in `reverse(v)`, return the corresponding index in `v` so that
Given an index `i` in [`reverse(v)`](@ref), return the corresponding index in `v` so that
`v[reverseind(v,i)] == reverse(v)[i]`. (This can be nontrivial in the case where `v` is a
Unicode string.)
Copy link
Member

Choose a reason for hiding this comment

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

BTW, "Unicode string" is a weird terminology since now all strings support Unicode. Maybe just remove that sentence? Or say that it's nontrivial because of non-ASCII characters.

@JeffBezanson JeffBezanson merged commit c8f1c55 into master Sep 21, 2017
@JeffBezanson JeffBezanson deleted the stevengj-patch-1 branch September 21, 2017 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation strings "Strings!"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants