diff --git a/base/char.jl b/base/char.jl index 0d976f1663462..24076d6373578 100644 --- a/base/char.jl +++ b/base/char.jl @@ -7,7 +7,6 @@ convert(::Type{Char}, x::Float64) = Char(convert(UInt32, x)) typemax(::Type{Char}) = Char(typemax(UInt32)) typemin(::Type{Char}) = Char(typemin(UInt32)) -## character operations & comparisons ## size(c::Char) = () size(c::Char,d) = convert(Int, d) < 1 ? throw(BoundsError()) : 1 ndims(c::Char) = 0 @@ -28,7 +27,6 @@ done(c::Char, state) = state isempty(c::Char) = false in(x::Char, y::Char) = x == y - ==(x::Char, y::Char) = UInt32(x) == UInt32(y) ==(x::Char, y::Integer) = UInt32(x) == y ==(x::Integer, y::Char) = x == UInt32(y) @@ -37,25 +35,15 @@ isless(x::Char, y::Char) = isless(UInt32(x), UInt32(y)) isless(x::Char, y::Integer) = isless(UInt32(x), y) isless(x::Integer, y::Char) = isless(x, UInt32(y)) -# numeric operations - -# ordinal operations -+(x::Char , y::Integer) = reinterpret(Char, Int32(x) + Int32(y)) +-(x::Char, y::Char) = Int(x) - Int(y) +-(x::Char, y::Integer) = reinterpret(Char, Int32(x) - Int32(y)) ++(x::Char, y::Integer) = reinterpret(Char, Int32(x) + Int32(y)) +(x::Integer, y::Char) = y + x --(x::Char , y::Char) = Int(x) - Int(y) --(x::Char , y::Integer) = reinterpret(Char, Int32(x) - Int32(y)) - -# bitwise operations -(~)(x::Char) = Char(~UInt32(x)) -(&)(x::Char, y::Char) = Char(UInt32(x) & UInt32(y)) -(|)(x::Char, y::Char) = Char(UInt32(x) | UInt32(y)) -($)(x::Char, y::Char) = Char(UInt32(x) $ UInt32(y)) bswap(x::Char) = Char(bswap(UInt32(x))) -## printing & showing characters ## print(io::IO, c::Char) = (write(io, c); nothing) -show(io::IO, c::Char) = begin +function show(io::IO, c::Char) print(io, '\'') print_escaped(io, utf32(c), "'") print(io, '\'') diff --git a/base/deprecated.jl b/base/deprecated.jl index 0895070d30544..e49bb6bada70b 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -435,3 +435,8 @@ export float32_isvalid, float64_isvalid @deprecate BigFloat(s::AbstractString) parse(BigFloat,s) @deprecate BigInt(s::AbstractString) parse(BigInt,s) + +@deprecate (~)(x::Char) Char(~UInt32(x)) +@deprecate (&)(x::Char, y::Char) Char(UInt32(x) & UInt32(y)) +@deprecate (|)(x::Char, y::Char) Char(UInt32(x) | UInt32(y)) +@deprecate ($)(x::Char, y::Char) Char(UInt32(x) $ UInt32(y))