-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Use predicate function in lstrip
etc.
#27232
Conversation
base/strings/util.jl
Outdated
end | ||
SubString(s, e+1, e) | ||
end | ||
lstrip(s::AbstractString) = lstrip(isspace, f) | ||
lstrip(s::AbstractString, chars::Chars) = lstrip(c -> c in chars, s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in(chars)
Perhaps the asymmetry between |
Yes: since We could even get rid of it altogether? It isn't that hard to write |
I'll leave the decision on the |
base/strings/util.jl
Outdated
end | ||
SubString(s, 1, 0) | ||
end | ||
rstrip(s::AbstractString) = rstrip(isspace, f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A typo?
rstrip(s::AbstractString) = rstrip(isspace, f)
should be rstrip(s::AbstractString) = rstrip(isspace, s)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems lstrip
and strip
also have this typo.
Changing this to always use a function would be in line with the |
Triage is in favor so let's merge if this passes CI. Also in favor of stripping all Unicode whitespace. |
Should we deprecate |
Ah, I assume that is what you were implying. |
Eh, deprecating it would be ok but doesn't seem urgent. |
Note that |
Looks like there's a still a use of the deprecated --- a/base/mpfr.jl
+++ b/base/mpfr.jl
@@ -932,7 +932,7 @@ function _prettify_bigfloat(s::String)::String
if !occursin('.', mantissa)
mantissa = string(mantissa, '.')
end
- mantissa = rstrip(mantissa, '0')
+ mantissa = rstrip(==('0'), mantissa)
if endswith(mantissa, '.')
mantissa = string(mantissa, '0')
end |
Another one: --- a/stdlib/Markdown/src/GitHub/GitHub.jl
+++ b/stdlib/Markdown/src/GitHub/GitHub.jl
@@ -9,7 +9,7 @@ function fencedcode(stream::IO, block::MD)
skip(stream, -1)
ch = read(stream, Char)
trailing = strip(readline(stream))
- flavor = lstrip(trailing, ch)
+ flavor = lstrip(==(ch), trailing)
n = 3 + length(trailing) - length(flavor)
# inline code block |
Looks like this broke some doctests, and will also need to be updated in Documenter. |
Maybe this is a sign that we should leave it alone? |
Nah. Just need to adjust the |
Can you point to the broken docstrings? I can't see any. |
Looking at JuliaDocs/Documenter.jl#731, I'm not 100% convinced it's a strict improvement. Additionally, considering that the behaviour will be different than |
They're showing up in the Travis log: https://travis-ci.org/JuliaLang/julia/jobs/383852269#L2958.
Does there need to be a 1-1 correspondence with |
I agree it sounds a bit weird to require using |
I have to agree that there doesn't seem to be much harm in leaving the old |
Okay, should we switch the argument order then, so that it is While characters and character sets are fine, I'm not sure how regexes would work, since it operates on a character basis. |
The current |
I also don't think we should switch the order. Is there much to do here then? |
I've also come around to thinking that this change may not actually be worthwhile... |
I think we should still allow predicate functions, since they can be much more efficient (e.g. checking ranges, short-circuiting if there are no non-ASCII chars). I've opened a simpler PR: #27309 |
Closed in favour of #27309 (for now...) |
Fixes #27211. Should be non-breaking.