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

Rename isalpha to isletter #27077

Merged
merged 1 commit into from
May 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,8 @@ Deprecated or removed

* `isnumber` has been renamed to `isnumeric` ([#25021]).

* `isalpha` has been renamed to `isletter` ([#26932]).

* `is_assigned_char` and `normalize_string` have been renamed to `isassigned` and
`normalize`, and moved to the new `Unicode` standard library module.
`graphemes` has also been moved to that module ([#25021]).
Expand Down Expand Up @@ -1488,3 +1490,4 @@ Command-line option changes
[#26600]: https://github.com/JuliaLang/julia/issues/26600
[#26670]: https://github.com/JuliaLang/julia/issues/26670
[#26775]: https://github.com/JuliaLang/julia/issues/26775
[#26932]: https://github.com/JuliaLang/julia/issues/26932
5 changes: 4 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ end
@deprecate_moved sum_kbn "KahanSummation"
@deprecate_moved cumsum_kbn "KahanSummation"

@deprecate isalnum(c::Char) isalpha(c) || isnumeric(c)
@deprecate isalnum(c::Char) isletter(c) || isnumeric(c)
@deprecate isgraph(c::Char) isprint(c) && !isspace(c)
@deprecate isnumber(c::Char) isnumeric(c)

Expand Down Expand Up @@ -1636,6 +1636,9 @@ end
@deprecate ucfirst uppercasefirst
@deprecate lcfirst lowercasefirst

# Issue #26932
@deprecate isalpha isletter

function search(buf::IOBuffer, delim::UInt8)
Base.depwarn("search(buf::IOBuffer, delim::UInt8) is deprecated: use occursin(delim, buf) or readuntil(buf, delim) instead", :search)
p = pointer(buf.data, buf.ptr)
Expand Down
2 changes: 1 addition & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,10 @@ export
escape_string,
hex2bytes,
hex2bytes!,
isalpha,
isascii,
iscntrl,
isdigit,
isletter,
islowercase,
isnumeric,
isprint,
Expand Down
4 changes: 2 additions & 2 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,10 @@ function which computes the boolean negation of `f`.
julia> str = "∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε"
"∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε"

julia> filter(isalpha, str)
julia> filter(isletter, str)
"εδxyδfxfyε"

julia> filter(!isalpha, str)
julia> filter(!isletter, str)
"∀ > 0, ∃ > 0: |-| < ⇒ |()-()| < "
```
"""
Expand Down
2 changes: 1 addition & 1 deletion base/strings/strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include("strings/substring.jl")
include("strings/search.jl")
include("strings/unicode.jl")

import .Unicode: textwidth, islowercase, isuppercase, isalpha, isdigit, isnumeric, iscntrl, ispunct,
import .Unicode: textwidth, islowercase, isuppercase, isletter, isdigit, isnumeric, iscntrl, ispunct,
isspace, isprint, isxdigit, lowercase, uppercase, titlecase, lowercasefirst, uppercasefirst

include("strings/util.jl")
Expand Down
14 changes: 7 additions & 7 deletions base/strings/unicode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,25 +347,25 @@ false
isdigit(c::AbstractChar) = '0' <= c <= '9'

"""
isalpha(c::AbstractChar) -> Bool
isletter(c::AbstractChar) -> Bool

Tests whether a character is alphabetic.
A character is classified as alphabetic if it belongs to the Unicode general
Test whether a character is a letter.
A character is classified as a letter if it belongs to the Unicode general
category Letter, i.e. a character whose category code begins with 'L'.

# Examples
```jldoctest
julia> isalpha('❤')
julia> isletter('❤')
false

julia> isalpha('α')
julia> isletter('α')
true

julia> isalpha('9')
julia> isletter('9')
false
```
"""
isalpha(c::AbstractChar) = UTF8PROC_CATEGORY_LU <= category_code(c) <= UTF8PROC_CATEGORY_LO
isletter(c::AbstractChar) = UTF8PROC_CATEGORY_LU <= category_code(c) <= UTF8PROC_CATEGORY_LO

"""
isnumeric(c::AbstractChar) -> Bool
Expand Down
2 changes: 1 addition & 1 deletion doc/src/base/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ Base.thisind
Base.nextind
Base.prevind
Base.textwidth
Base.isalpha
Base.isascii
Base.iscntrl
Base.isdigit
Base.isletter
Base.islowercase
Base.isnumeric
Base.isprint
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Dates/src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ end
max_pos = maxchars <= 0 ? len : min(len, nextind(str, i, maxchars-1))
@inbounds while i <= max_pos
c, ii = next(str, i)
if isalpha(c)
if isletter(c)
word_end = i
else
break
Expand Down
2 changes: 1 addition & 1 deletion stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function matchinds(needle, haystack; acronym = false)
isempty(chars) && break
while chars[1] == ' ' popfirst!(chars) end # skip spaces
if lowercase(char) == lowercase(chars[1]) &&
(!acronym || !isalpha(lastc))
(!acronym || !isletter(lastc))
push!(is, i)
popfirst!(chars)
end
Expand Down
16 changes: 8 additions & 8 deletions stdlib/Unicode/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ end
alphas=vcat(alower,ulower,aupper,uupper,nocase)

for c in alphas
@test isalpha(c) == true
@test isletter(c) == true
@test isnumeric(c) == false
end

Expand All @@ -132,7 +132,7 @@ end

alnums=vcat(alphas,anumber,unumber)
for c in alnums
@test isalpha(c) || isnumeric(c)
@test isletter(c) || isnumeric(c)
@test ispunct(c) == false
end

Expand All @@ -144,7 +144,7 @@ end

for c in vcat(apunct,upunct)
@test ispunct(c) == true
@test !isalpha(c) && !isnumeric(c)
@test !isletter(c) && !isnumeric(c)
end

for c in vcat(alnums,asymbol,usymbol,apunct,upunct)
Expand Down Expand Up @@ -180,27 +180,27 @@ end

for c in vcat(acontrol, acntrl_space, latincontrol)
@test iscntrl(c) == true
@test !isalpha(c) && !isnumeric(c)
@test !isletter(c) && !isnumeric(c)
@test isprint(c) == false
end

for c in ucontrol #non-latin1 controls
if c!=Char(0x0085)
@test iscntrl(c) == false
@test isspace(c) == false
@test !isalpha(c) && !isnumeric(c)
@test !isletter(c) && !isnumeric(c)
@test isprint(c) == false
end
end

@test all(isspace," \t \n \r ")
@test !all(isprint," \t \n \r ")
@test !all(isalpha," \t \n \r ")
@test !all(isletter," \t \n \r ")
@test !all(isnumeric," \t \n \r ")
@test !all(ispunct," \t \n \r ")

@test !all(isspace,"ΣβΣβ")
@test all(isalpha,"ΣβΣβ")
@test all(isletter,"ΣβΣβ")
@test all(isprint,"ΣβΣβ")
@test !all(isuppercase,"ΣβΣβ")
@test !all(islowercase,"ΣβΣβ")
Expand All @@ -210,7 +210,7 @@ end

@test all(isnumeric,"23435")
@test all(isdigit,"23435")
@test !all(isalpha,"23435")
@test !all(isletter,"23435")
@test all(iscntrl,string(Char(0x0080)))
@test all(ispunct, "‡؟჻")

Expand Down
2 changes: 1 addition & 1 deletion test/iobuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ end

for char in ['@','߷','࿊','𐋺']
io = IOBuffer("alphabeticalstuff$char")
@test !eof(skipchars(isalpha, io))
@test !eof(skipchars(isletter, io))
@test read(io, Char) == char
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
for (byte,char) in zip(1:4, ('@','߷','࿊','𐋺'))
append_to_file("abcdef$char")
@test Base.codelen(char) == byte
@test !eof(skipchars(isalpha, file))
@test !eof(skipchars(isletter, file))
@test read(file, Char) == char
end
end
Expand Down