-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Add Compat.Unicode for standard library Unicode #432
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -752,13 +752,6 @@ end | |
export BitSet | ||
end | ||
|
||
# 0.7.0-DEV.1930 | ||
@static if !isdefined(Base, :textwidth) | ||
textwidth(c::Char) = charwidth(c) | ||
textwidth(c::AbstractString) = strwidth(c) | ||
export textwidth | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what the procedure with deprecating a Compat supported change is. Since the rule for Compat.jl is to use the latest syntax it seemed reasonable to move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer a deprecation over a breaking change. It is quite common for packages to require a fairly recent Compat version, so if others need to set an upper bound, that could be rather unfortunate. But I have no idea want the standard procedure is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a deprecation for this so the transition should be non-breaking. |
||
# 0.7.0-DEV.2116 | ||
@static if VERSION < v"0.7.0-DEV.2116" | ||
import Base: spdiagm | ||
|
@@ -874,6 +867,47 @@ end | |
export ComplexF64 | ||
end | ||
|
||
# 0.7.0-DEV.2915 | ||
module Unicode | ||
export graphemes, textwidth, isvalid, | ||
islower, isupper, isalpha, isdigit, isxdigit, isnumeric, isalnum, | ||
iscntrl, ispunct, isspace, isprint, isgraph, | ||
lowercase, uppercase, titlecase, lcfirst, ucfirst | ||
|
||
if VERSION < v"0.7.0-DEV.2915" | ||
# 0.7.0-DEV.1930 | ||
if !isdefined(Base, :textwidth) | ||
textwidth(c::Char) = charwidth(c) | ||
textwidth(c::AbstractString) = strwidth(c) | ||
end | ||
|
||
isnumeric(c::Char) = isnumber(c) | ||
|
||
# 0.6.0-dev.1404 (https://github.com/JuliaLang/julia/pull/19469) | ||
if !isdefined(Base, :titlecase) | ||
titlecase(c::Char) = isascii(c) ? ('a' <= c <= 'z' ? c - 0x20 : c) : | ||
Char(ccall(:utf8proc_totitle, UInt32, (UInt32,), c)) | ||
|
||
function titlecase(s::AbstractString) | ||
startword = true | ||
b = IOBuffer() | ||
for c in s | ||
if isspace(c) | ||
print(b, c) | ||
startword = true | ||
else | ||
print(b, startword ? titlecase(c) : c) | ||
startword = false | ||
end | ||
end | ||
return String(take!(b)) | ||
end | ||
end | ||
else | ||
using Unicode | ||
end | ||
end | ||
|
||
include("deprecated.jl") | ||
|
||
end # module Compat |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,3 +188,7 @@ else | |
import Base.@irrational | ||
import Base.LinAlg.BLAS.@blasfunc | ||
end | ||
|
||
if VERSION < v"0.7.0-DEV.2915" | ||
Base.@deprecate textwidth Compat.Unicode.textwidth | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the justification for these lines. They are annoying as they print deprecation warnings on Julia 0.6. These can appear for packages which worked perfectly well before, just because Compat has been updated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally haven't seen this scenario where previous Compat code was required to be moved. There may be a standard procedure on how to handle this for which I am unaware. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I see the logic. However I think it's bad to generate tons of deprecation warnings on Julia 0.6 for packages which worked perfectly fine until now. For example, DataFrames is very painful to use right now because of this. I think the best approach is to keep exporting this function on Julia < 0.7 since it's supported by Julia 0.6, but not on Julia 0.7. We don't need to deprecate the function ourselves since Julia takes care of that already. See #437. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me. We should think about making a CONTRIBUTING.md to Compat.jl to clarify these kind of details. |
||
end |
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.
The diff is messed up here. I moved all of the
using X
notes into the "Module Aliases" section.