diff --git a/base/associative.jl b/base/associative.jl index 67d2944215b7b5..4baae3832a21eb 100644 --- a/base/associative.jl +++ b/base/associative.jl @@ -251,7 +251,7 @@ const hasha_seed = UInt === UInt64 ? 0x6d35bb51952d5539 : 0x952d5539 function hash(a::Associative, h::UInt) h = hash(hasha_seed, h) for (k,v) in a - h = xor(h, hash(k, hash(v))) + h ⊻= hash(k, hash(v)) end return h end diff --git a/base/broadcast.jl b/base/broadcast.jl index 0049341038b10f..c26e66ae4375e6 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -498,9 +498,9 @@ function broadcast_bitarrays(scalarf, bitf, A::AbstractArray{Bool}, B::AbstractA return F end -biteq(a::UInt64, b::UInt64) = xor(~a, b) +biteq(a::UInt64, b::UInt64) = ~a ⊻ b bitlt(a::UInt64, b::UInt64) = ~a & b -bitneq(a::UInt64, b::UInt64) = xor(a, b) +bitneq(a::UInt64, b::UInt64) = a ⊻ b bitle(a::UInt64, b::UInt64) = ~a | b .==(A::AbstractArray{Bool}, B::AbstractArray{Bool}) = broadcast_bitarrays(==, biteq, A, B) diff --git a/base/char.jl b/base/char.jl index 82c88cdd88a695..79a1b43dec1e37 100644 --- a/base/char.jl +++ b/base/char.jl @@ -33,7 +33,7 @@ in(x::Char, y::Char) = x == y isless(x::Char, y::Char) = UInt32(x) < UInt32(y) const hashchar_seed = 0xd4d64234 -hash(x::Char, h::UInt) = hash_uint64(xor((UInt64(x)+hashchar_seed)<<32, UInt64(h))) +hash(x::Char, h::UInt) = hash_uint64(((UInt64(x)+hashchar_seed)<<32) ⊻ UInt64(h)) -(x::Char, y::Char) = Int(x) - Int(y) -(x::Char, y::Integer) = Char(Int32(x) - Int32(y)) diff --git a/base/combinatorics.jl b/base/combinatorics.jl index 103dc68a891440..c46f80f321a210 100644 --- a/base/combinatorics.jl +++ b/base/combinatorics.jl @@ -73,7 +73,7 @@ function isperm(A) n = length(A) used = falses(n) for a in A - (0 < a <= n) && (used[a] = xor(used[a], true)) || return false + (0 < a <= n) && (used[a] ⊻= true) || return false end true end diff --git a/base/complex.jl b/base/complex.jl index 095ab8342cab82..e101480ab36496 100644 --- a/base/complex.jl +++ b/base/complex.jl @@ -161,8 +161,8 @@ const hash_0_imag = hash(0, h_imag) function hash(z::Complex, h::UInt) # TODO: with default argument specialization, this would be better: - # hash(real(z), h $ hash(imag(z), h $ h_imag) $ hash(0, h $ h_imag)) - hash(real(z), xor(h, hash(imag(z), h_imag), hash_0_imag)) + # hash(real(z), h ⊻ hash(imag(z), h ⊻ h_imag) ⊻ hash(0, h ⊻ h_imag)) + hash(real(z), h ⊻ hash(imag(z), h_imag) ⊻ hash_0_imag) end ## generic functions of complex numbers ## diff --git a/base/dSFMT.jl b/base/dSFMT.jl index c65c699a5c3469..5236c8def9cf35 100644 --- a/base/dSFMT.jl +++ b/base/dSFMT.jl @@ -115,19 +115,19 @@ function dsfmt_jump_add!(dest::Vector{UInt64}, src::Vector{UInt64}) while i <= N-diff j = i*2-1 p = j + diff*2 - dest[j] = xor(dest[j], src[p]) - dest[j+1] = xor(dest[j+1], src[p+1]) + dest[j] ⊻= src[p] + dest[j+1] ⊻= src[p+1] i += 1 end while i <= N j = i*2-1 p = j + (diff - N)*2 - dest[j] = xor(dest[j], src[p]) - dest[j+1] = xor(dest[j+1], src[p+1]) + dest[j] ⊻= src[p] + dest[j+1] ⊻= src[p+1] i += 1 end - dest[N*2+1] = xor(dest[N*2+1], src[N*2+1]) - dest[N*2+2] = xor(dest[N*2+2], src[N*2+2]) + dest[N*2+1] ⊻= src[N*2+1] + dest[N*2+2] ⊻= src[N*2+2] return dest end diff --git a/base/deprecated.jl b/base/deprecated.jl index c0a2410dfbfcfb..ed8c3a025896c2 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1023,7 +1023,11 @@ end)) @deprecate ipermutedims(A::AbstractArray,p) permutedims(A, invperm(p)) # 18696 -@deprecate ($) xor +function ($)(x, y) + depwarn("`x \$ y` is deprecated. use `xor(x, y)` or `x ⊻ y` instead.", :$) + xor(x, y) +end +export $ @deprecate is (===) diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl index 740f1bce56b256..908a3d194c3c8c 100644 --- a/base/docs/helpdb/Base.jl +++ b/base/docs/helpdb/Base.jl @@ -3355,6 +3355,7 @@ dawson """ xor(x, y) + ⊻(x, y) Bitwise exclusive or. """ diff --git a/base/exports.jl b/base/exports.jl index 75a4b36c41836e..6de80ae41d65c9 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -206,6 +206,7 @@ export ≡, ≢, xor, + ⊻, %, ÷, &, diff --git a/base/fastmath.jl b/base/fastmath.jl index 93dd88f3c9ec7a..bce8637b7fa406 100644 --- a/base/fastmath.jl +++ b/base/fastmath.jl @@ -153,7 +153,7 @@ mul_fast{T<:FloatTypes}(x::T, y::T, zs::T...) = cmp_fast{T<:FloatTypes}(x::T, y::T) = ifelse(x==y, 0, ifelse(x 0, y > 0), r+y, r) + ifelse((r > 0) ⊻ (y > 0), r+y, r) end end diff --git a/base/float.jl b/base/float.jl index 4191bd29d6c608..b89ec91e7c9093 100644 --- a/base/float.jl +++ b/base/float.jl @@ -361,7 +361,7 @@ _default_type(T::Union{Type{Real},Type{AbstractFloat}}) = Float64 ## floating point arithmetic ## -(x::Float64) = box(Float64,neg_float(unbox(Float64,x))) -(x::Float32) = box(Float32,neg_float(unbox(Float32,x))) --(x::Float16) = reinterpret(Float16, xor(reinterpret(UInt16,x), 0x8000)) +-(x::Float16) = reinterpret(Float16, reinterpret(UInt16,x) ⊻ 0x8000) for op in (:+,:-,:*,:/,:\,:^) @eval ($op)(a::Float16, b::Float16) = Float16(($op)(Float32(a), Float32(b))) @@ -400,7 +400,7 @@ function mod{T<:AbstractFloat}(x::T, y::T) r = rem(x,y) if r == 0 copysign(r,y) - elseif xor(r > 0, y > 0) + elseif (r > 0) ⊻ (y > 0) r+y else r @@ -531,7 +531,7 @@ const hx_NaN = hx(UInt64(0), NaN, UInt(0 )) hash(x::UInt64, h::UInt) = hx(x, Float64(x), h) hash(x::Int64, h::UInt) = hx(reinterpret(UInt64,abs(x)), Float64(x), h) -hash(x::Float64, h::UInt) = isnan(x) ? xor(hx_NaN, h) : hx(box(UInt64,fptoui(unbox(Float64,abs(x)))), x, h) +hash(x::Float64, h::UInt) = isnan(x) ? (hx_NaN ⊻ h) : hx(box(UInt64,fptoui(unbox(Float64,abs(x)))), x, h) hash(x::Union{Bool,Int8,UInt8,Int16,UInt16,Int32,UInt32}, h::UInt) = hash(Int64(x), h) hash(x::Float32, h::UInt) = hash(Float64(x), h) @@ -577,7 +577,7 @@ function nextfloat(f::Union{Float16,Float32,Float64}, d::Integer) fu = fumax else du = da % U - if xor(fneg, dneg) + if fneg ⊻ dneg if du > fu fu = min(fumax, du - fu) fneg = !fneg diff --git a/base/gmp.jl b/base/gmp.jl index 1d0deb3f8b35d9..6da4d33af4d491 100644 --- a/base/gmp.jl +++ b/base/gmp.jl @@ -194,7 +194,7 @@ function convert{T<:Signed}(::Type{T}, x::BigInt) else 0 <= n <= cld(sizeof(T),sizeof(Limb)) || throw(InexactError()) y = x % T - xor(x.size > 0, y > 0) && throw(InexactError()) # catch overflow + (x.size > 0) ⊻ (y > 0) && throw(InexactError()) # catch overflow y end end diff --git a/base/hashing.jl b/base/hashing.jl index 0cda93a3f5ecd0..8e83b21d8ecf36 100644 --- a/base/hashing.jl +++ b/base/hashing.jl @@ -14,11 +14,11 @@ hash(x::ANY, h::UInt) = 3*object_id(x) - h function hash_64_64(n::UInt64) local a::UInt64 = n a = ~a + a << 21 - a = xor(a, a >> 24) + a = a ⊻ a >> 24 a = a + a << 3 + a << 8 - a = xor(a, a >> 14) + a = a ⊻ a >> 14 a = a + a << 2 + a << 4 - a = xor(a, a >> 28) + a = a ⊻ a >> 28 a = a + a << 31 return a end @@ -26,22 +26,22 @@ end function hash_64_32(n::UInt64) local a::UInt64 = n a = ~a + a << 18 - a = xor(a, a >> 31) + a = a ⊻ a >> 31 a = a * 21 - a = xor(a, a >> 11) + a = a ⊻ a >> 11 a = a + a << 6 - a = xor(a, a >> 22) + a = a ⊻ a >> 22 return a % UInt32 end function hash_32_32(n::UInt32) local a::UInt32 = n a = a + 0x7ed55d16 + a << 12 - a = xor(a, 0xc761c23c, a >> 19) + a = a ⊻ 0xc761c23c ⊻ a >> 19 a = a + 0x165667b1 + a << 5 - a = a + xor(0xd3a2646c, a << 9) + a = a + 0xd3a2646c ⊻ a << 9 a = a + 0xfd7046c5 + a << 3 - a = xor(a, 0xb55a4f09, a >> 16) + a = a ⊻ 0xb55a4f09 ⊻ a >> 16 return a end diff --git a/base/hashing2.jl b/base/hashing2.jl index 35ba3a45909341..dead6703eeede9 100644 --- a/base/hashing2.jl +++ b/base/hashing2.jl @@ -3,11 +3,11 @@ ## efficient value-based hashing of integers ## function hash_integer(n::Integer, h::UInt) - h = xor(hash_uint(xor(n % UInt, h)), h) + h ⊻= hash_uint((n % UInt) ⊻ h) n = abs(n) n >>>= sizeof(UInt) << 3 while n != 0 - h = xor(hash_uint(xor(n % UInt, h)), h) + h ⊻= hash_uint((n % UInt) ⊻ h) n >>>= sizeof(UInt) << 3 end return h @@ -18,9 +18,9 @@ function hash_integer(n::BigInt, h::UInt) s == 0 && return hash_integer(0, h) p = convert(Ptr{UInt}, n.d) b = unsafe_load(p) - h = xor(hash_uint(xor(ifelse(s < 0, -b, b), h)), h) + h ⊻= hash_uint(ifelse(s < 0, -b, b) ⊻ h) for k = 2:abs(s) - h = xor(hash_uint(xor(unsafe_load(p, k), h)), h) + h ⊻= hash_uint(unsafe_load(p, k) ⊻ h) end return h end diff --git a/base/int.jl b/base/int.jl index 3d069c8fb81ef7..3ee0b62e4b59f7 100644 --- a/base/int.jl +++ b/base/int.jl @@ -76,7 +76,7 @@ flipsign(x::Signed, y::Float32) = flipsign(x, reinterpret(Int32,y)) flipsign(x::Signed, y::Float64) = flipsign(x, reinterpret(Int64,y)) flipsign(x::Signed, y::Real) = flipsign(x, -oftype(x,signbit(y))) -copysign(x::Signed, y::Signed) = flipsign(x, xor(x,y)) +copysign(x::Signed, y::Signed) = flipsign(x, x ⊻ y) copysign(x::Signed, y::Float16) = copysign(x, reinterpret(Int16,y)) copysign(x::Signed, y::Float32) = copysign(x, reinterpret(Int32,y)) copysign(x::Signed, y::Float64) = copysign(x, reinterpret(Int64,y)) @@ -149,7 +149,7 @@ rem{T<:BitUnsigned64}(x::T, y::T) = box(T,checked_urem_int(unbox(T,x),unbox(T,y) fld{T<:Unsigned}(x::T, y::T) = div(x,y) function fld{T<:Integer}(x::T, y::T) d = div(x,y) - d - (signbit(xor(x,y)) & (d*y!=x)) + d - (signbit(x ⊻ y) & (d*y!=x)) end # cld(x,y) = div(x,y) + ((x>0) == (y>0) && rem(x,y) != 0 ? 1 : 0) diff --git a/base/intset.jl b/base/intset.jl index 22703a665483b3..2200c73d6ca5b3 100644 --- a/base/intset.jl +++ b/base/intset.jl @@ -140,7 +140,7 @@ function symdiff!(s::IntSet, n::Integer) elseif n < 0 throw(ArgumentError("IntSet elements cannot be negative")) end - s.bits[n>>5 + 1] = xor(s.bits[n>>5 + 1], UInt32(1)<<(n&31)) + s.bits[n>>5 + 1] ⊻= UInt32(1)<<(n&31) return s end @@ -282,14 +282,14 @@ function symdiff!(s::IntSet, s2::IntSet) end lim = length(s2.bits) for n = 1:lim - s.bits[n] = xor(s.bits[n], s2.bits[n]) + s.bits[n] ⊻= s2.bits[n] end if s2.fill1s for n=lim+1:length(s.bits) s.bits[n] = ~s.bits[n] end end - s.fill1s = xor(s.fill1s, s2.fill1s) + s.fill1s ⊻= s2.fill1s s end diff --git a/base/latex_symbols.jl b/base/latex_symbols.jl index 86e88a950b4b24..ffa122464446e8 100644 --- a/base/latex_symbols.jl +++ b/base/latex_symbols.jl @@ -83,6 +83,7 @@ const latex_symbols = Dict( "\\pppprime" => "⁗", "\\backpprime" => "‶", "\\backppprime" => "‷", + "\\xor" => "⊻", # Superscripts "\\^0" => "⁰", diff --git a/base/math.jl b/base/math.jl index 335b829ff34b71..6fba129a1622f1 100644 --- a/base/math.jl +++ b/base/math.jl @@ -393,10 +393,10 @@ function significand{T<:AbstractFloat}(x::T) if xe == 0 # x is subnormal x == 0 && return x xs = xu & sign_mask(T) - xu = xor(xu, xs) + xu ⊻= xs m = leading_zeros(xu)-exponent_bits(T) xu <<= m - xu = xor(xu, xs) + xu ⊻= xs elseif xe == exponent_mask(T) # NaN or Inf return x end @@ -419,7 +419,7 @@ function frexp{T<:AbstractFloat}(x::T) xs == 0 && return x, 0 # +-0 m = unsigned(leading_zeros(xs) - exponent_bits(T)) xs <<= m - xu = xor(xs, (xu & sign_mask(T))) + xu = xs ⊻ (xu & sign_mask(T)) k = 1 - signed(m) end k -= (exponent_bias(T) - 1) diff --git a/base/operators.jl b/base/operators.jl index 3ff0583c29131c..5dfa0162d020d6 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -267,6 +267,8 @@ identity(x) = x (|)(x::Integer) = x xor(x::Integer) = x +const ⊻ = xor + # foldl for argument lists. expand recursively up to a point, then # switch to a loop. this allows small cases like `a+b+c+d` to be inlined # efficiently, without a major slowdown for `+(x...)` when `x` is big. @@ -1042,6 +1044,7 @@ export ∪, √, ∛, + ⊻, colon, hcat, vcat, @@ -1055,6 +1058,6 @@ import ..this_module: !, !=, xor, %, .%, ÷, .÷, &, *, +, -, .!=, .+, .-, .*, . .>=, .\, .^, /, //, <, <:, <<, <=, ==, >, >=, >>, .>>, .<<, >>>, <|, |>, \, ^, |, ~, !==, ===, >:, colon, hcat, vcat, hvcat, getindex, setindex!, transpose, ctranspose, - ≥, ≤, ≠, .≥, .≤, .≠, ⋅, ×, ∈, ∉, ∋, ∌, ⊆, ⊈, ⊊, ∩, ∪, √, ∛ + ≥, ≤, ≠, .≥, .≤, .≠, ⋅, ×, ∈, ∉, ∋, ∌, ⊆, ⊈, ⊊, ∩, ∪, √, ∛, ⊻ end diff --git a/base/random.jl b/base/random.jl index e8a91237450ade..fce69c2436b870 100644 --- a/base/random.jl +++ b/base/random.jl @@ -324,7 +324,7 @@ rand(r::Union{RandomDevice,MersenneTwister}, ::Type{Float32}) = function rand(r::MersenneTwister, ::Type{UInt64}) reserve(r, 2) - xor(rand_ui52_raw_inbounds(r) << 32, rand_ui52_raw_inbounds(r)) + rand_ui52_raw_inbounds(r) << 32 ⊻ rand_ui52_raw_inbounds(r) end function rand(r::MersenneTwister, ::Type{UInt128}) @@ -447,7 +447,7 @@ function rand!{T<:Union{Float16, Float32}}(r::MersenneTwister, A::Array{T}, ::Ty A128 = unsafe_wrap(Array, convert(Ptr{UInt128}, pointer(A)), n128) @inbounds for i in 1:n128 u = A128[i] - u = xor(u, u << 26) + u ⊻= u << 26 # at this point, the 64 low bits of u, "k" being the k-th bit of A128[i] and "+" the bit xor, are: # [..., 58+32,..., 53+27, 52+26, ..., 33+7, 32+6, ..., 27+1, 26, ..., 1] # the bits needing to be random are @@ -488,17 +488,17 @@ function rand!(r::MersenneTwister, A::Array{UInt128}, n::Int=length(A)) i = 0 @inbounds while n-i >= 5 u = A[i+=1] - A[n] = xor(A[n], u << 48) - A[n-1] = xor(A[n-1], u << 36) - A[n-2] = xor(A[n-2], u << 24) - A[n-3] = xor(A[n-3], u << 12) - n -= 4 + A[n] ⊻= u << 48 + A[n-=1] ⊻= u << 36 + A[n-=1] ⊻= u << 24 + A[n-=1] ⊻= u << 12 + n-=1 end end if n > 0 u = rand_ui2x52_raw(r) for i = 1:n - @inbounds A[i] = xor(A[i], u << 12*i) + @inbounds A[i] ⊻= u << 12*i end end A diff --git a/base/set.jl b/base/set.jl index a47a76460a0a42..3fc0c9045e4b0d 100644 --- a/base/set.jl +++ b/base/set.jl @@ -189,7 +189,7 @@ const hashs_seed = UInt === UInt64 ? 0x852ada37cfe8e0ce : 0xcfe8e0ce function hash(s::Set, h::UInt) h = hash(hashs_seed, h) for x in s - h = xor(h, hash(x)) + h ⊻= hash(x) end return h end diff --git a/base/show.jl b/base/show.jl index 1b76b80313cef6..2101c478e0e0a9 100644 --- a/base/show.jl +++ b/base/show.jl @@ -449,7 +449,7 @@ const uni_ops = Set{Symbol}([:(+), :(-), :(!), :(¬), :(~), :(<:), :(>:), :(√) const expr_infix_wide = Set{Symbol}([ :(=), :(+=), :(-=), :(*=), :(/=), :(\=), :(^=), :(&=), :(|=), :(÷=), :(%=), :(>>>=), :(>>=), :(<<=), :(.=), :(.+=), :(.-=), :(.*=), :(./=), :(.\=), :(.^=), :(.&=), :(.|=), :(.÷=), :(.%=), :(.>>>=), :(.>>=), :(.<<=), - :(&&), :(||), :(<:), :(=>), :($=)]) + :(&&), :(||), :(<:), :(=>), :($=), :(⊻=)]) const expr_infix = Set{Symbol}([:(:), :(->), Symbol("::")]) const expr_infix_any = union(expr_infix, expr_infix_wide) const all_ops = union(quoted_syms, uni_ops, expr_infix_any) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index b48ad0f7316312..4a24f4464dc90f 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -904,7 +904,7 @@ function _ispermutationvalid_permute!{Ti<:Integer,Tp<:Integer}(perm::AbstractVec n = length(perm) checkspace[1:n] = 0 for k in perm - (0 < k ≤ n) && ((checkspace[k] = xor(checkspace[k], 1)) == 1) || return false + (0 < k ≤ n) && ((checkspace[k] ⊻= 1) == 1) || return false end return true end diff --git a/doc/manual/mathematical-operations.rst b/doc/manual/mathematical-operations.rst index d19560db94e7f4..0c2f14bbec23e7 100644 --- a/doc/manual/mathematical-operations.rst +++ b/doc/manual/mathematical-operations.rst @@ -68,17 +68,17 @@ The following `bitwise operators `_ are supported on all primitive integer types: -=========== ========================================================================= -Expression Name -=========== ========================================================================= -``~x`` bitwise not -``x & y`` bitwise and -``x | y`` bitwise or -``xor(x, y)`` bitwise xor (exclusive or) -``x >>> y`` `logical shift `_ right -``x >> y`` `arithmetic shift `_ right -``x << y`` logical/arithmetic shift left -=========== ========================================================================= +=========== ========================================================================= +Expression Name +=========== ========================================================================= +``~x`` bitwise not +``x & y`` bitwise and +``x | y`` bitwise or +``x ⊻ y`` bitwise xor (exclusive or) +``x >>> y`` `logical shift `_ right +``x >> y`` `arithmetic shift `_ right +``x << y`` logical/arithmetic shift left +=========== ========================================================================= Here are some examples with bitwise operators: @@ -93,6 +93,9 @@ Here are some examples with bitwise operators: julia> 123 | 234 251 + julia> 123 ⊻ 234 + 145 + julia> xor(123, 234) 145 @@ -122,7 +125,7 @@ equivalent to writing ``x = x + 3``:: The updating versions of all the binary arithmetic and bitwise operators are:: - += -= *= /= \= ÷= %= ^= &= |= >>>= >>= <<= + += -= *= /= \= ÷= %= ^= &= |= ⊻= >>>= >>= <<= .. note:: @@ -344,11 +347,11 @@ Exponentiation ``^`` and its elementwise equivalent ``.^`` Fractions ``//`` and ``.//`` Multiplication ``* / % & \`` and ``.* ./ .% .\`` Bitshifts ``<< >> >>>`` and ``.<< .>> .>>>`` -Addition ``+ - |`` and ``.+ .-`` +Addition ``+ - | ⊻`` and ``.+ .-`` Syntax ``: ..`` followed by ``|>`` Comparisons ``> < >= <= == === != !== <:`` and ``.> .< .>= .<= .== .!=`` Control flow ``&&`` followed by ``||`` followed by ``?`` -Assignments ``= += -= *= /= //= \= ^= ÷= %= |= &= <<= >>= >>>=`` and ``.+= .-= .*= ./= .//= .\= .^= .÷= .%=`` +Assignments ``= += -= *= /= //= \= ^= ÷= %= |= &= ⊻= <<= >>= >>>=`` and ``.+= .-= .*= ./= .//= .\= .^= .÷= .%=`` ================= ============================================================================================= .. _man-elementary-functions: diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 63ccf0394cf592..5ac6dc5a65235d 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -7,7 +7,7 @@ ;; the way the lexer works, every prefix of an operator must also ;; be an operator. (define prec-assignment - (append! (add-dots '(= += -= *= /= //= |\\=| ^= ÷= %= <<= >>= >>>= |\|=| &=)) + (append! (add-dots '(= += -= *= /= //= |\\=| ^= ÷= %= <<= >>= >>>= |\|=| &= ⊻=)) '(:= => ~ $=))) (define prec-conditional '(?)) (define prec-arrow (append! @@ -77,7 +77,7 @@ ; operators that are special forms, not function names (define syntactic-operators - (append! (add-dots '(= += -= *= /= //= |\\=| ^= ÷= %= <<= >>= >>>= |\|=| &=)) + (append! (add-dots '(= += -= *= /= //= |\\=| ^= ÷= %= <<= >>= >>>= |\|=| &= ⊻=)) '(:= --> $= => && |\|\|| |.| ... ->))) (define syntactic-unary-operators '($ & |::|)) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 31e03d7f59549f..f67f783d682f61 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2055,6 +2055,8 @@ '&= lower-update-op '.&= lower-update-op '$= lower-update-op + '⊻= lower-update-op + '.⊻= lower-update-op '<<= lower-update-op '.<<= lower-update-op '>>= lower-update-op diff --git a/test/bigint.jl b/test/bigint.jl index de5a1a07949fc9..d6393bdabe2259 100644 --- a/test/bigint.jl +++ b/test/bigint.jl @@ -164,7 +164,7 @@ end @test ~BigInt(123) == -124 @test BigInt(123) & BigInt(234) == 106 @test BigInt(123) | BigInt(234) == 251 -@test xor(BigInt(123), BigInt(234)) == 145 +@test BigInt(123) ⊻ BigInt(234) == 145 @test gcd(BigInt(48), BigInt(180)) == 12 @test lcm(BigInt(48), BigInt(180)) == 720 diff --git a/test/bitarray.jl b/test/bitarray.jl index 956cf4e5e6920a..c53202e8ec91d3 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -1119,7 +1119,7 @@ let b1 = trues(v1) for i = 3:(v1-1), j = 2:i submask = b1 << (v1-j+1) @test findnext((b1 >> i) | submask, j) == i+1 - @test findnextnot(xor(~(b1 >> i), submask), j) == i+1 + @test findnextnot((~(b1 >> i)) ⊻ submask, j) == i+1 end end @@ -1276,7 +1276,7 @@ for l = [0, 1, 63, 64, 65, 127, 128, 129, 255, 256, 257, 6399, 6400, 6401] @test map(&, b1, b2) == map((x,y)->x&y, b1, b2) == b1 & b2 @test map(|, b1, b2) == map((x,y)->x|y, b1, b2) == b1 | b2 - @test map(xor, b1, b2) == map((x,y)->xor(x,y), b1, b2) == xor(b1, b2) + @test map(⊻, b1, b2) == map((x,y)->x⊻y, b1, b2) == b1 ⊻ b2 == xor(b1, b2) @test map(^, b1, b2) == map((x,y)->x^y, b1, b2) == b1 .^ b2 @test map(*, b1, b2) == map((x,y)->x*y, b1, b2) == b1 .* b2 @@ -1301,7 +1301,7 @@ for l = [0, 1, 63, 64, 65, 127, 128, 129, 255, 256, 257, 6399, 6400, 6401] @test map!(&, b, b1, b2) == map!((x,y)->x&y, b, b1, b2) == b1 & b2 == b @test map!(|, b, b1, b2) == map!((x,y)->x|y, b, b1, b2) == b1 | b2 == b - @test map!(xor, b, b1, b2) == map!((x,y)->xor(x,y), b, b1, b2) == xor(b1, b2) == b + @test map!(⊻, b, b1, b2) == map!((x,y)->x⊻y, b, b1, b2) == b1 ⊻ b2 == xor(b1, b2) == b @test map!(^, b, b1, b2) == map!((x,y)->x^y, b, b1, b2) == b1 .^ b2 == b @test map!(*, b, b1, b2) == map!((x,y)->x*y, b, b1, b2) == b1 .* b2 == b diff --git a/test/numbers.jl b/test/numbers.jl index 945a4122d6d069..bb4ace142d94af 100644 --- a/test/numbers.jl +++ b/test/numbers.jl @@ -26,6 +26,10 @@ const ≣ = isequal # convenient for comparing NaNs @test false | true == true @test true | true == true +@test false ⊻ false == false +@test true ⊻ false == true +@test false ⊻ true == true +@test true ⊻ true == false @test xor(false, false) == false @test xor(true, false) == true @test xor(false, true) == true diff --git a/test/operators.jl b/test/operators.jl index 35ff0a6ccaf967..622afc9fa14df9 100644 --- a/test/operators.jl +++ b/test/operators.jl @@ -44,6 +44,7 @@ p = 1=>:foo @test (|)(2) == 2 @test xor(2) == 2 +@test (⊻)(2) == 2 # @test ctranspose('a') == 'a' # (c)transpose of Chars no longer supported diff --git a/test/reduce.jl b/test/reduce.jl index 6f07967553edcc..f1a8f3d41c9ef2 100644 --- a/test/reduce.jl +++ b/test/reduce.jl @@ -10,11 +10,11 @@ @test Base.mapfoldl(abs2, /, 2:5) ≈ 1/900 @test Base.mapfoldl(abs2, /, 10, 2:5) ≈ 1/1440 -@test Base.mapfoldl((x)-> xor(x, true), &, true, [true false true false false]) == false -@test Base.mapfoldl((x)-> xor(x, true), &, [true false true false false]) == false +@test Base.mapfoldl((x)-> x ⊻ true, &, true, [true false true false false]) == false +@test Base.mapfoldl((x)-> x ⊻ true, &, [true false true false false]) == false -@test Base.mapfoldl((x)-> xor(x, true), |, [true false true false false]) == true -@test Base.mapfoldl((x)-> xor(x, true), |, false, [true false true false false]) == true +@test Base.mapfoldl((x)-> x ⊻ true, |, [true false true false false]) == true +@test Base.mapfoldl((x)-> x ⊻ true, |, false, [true false true false false]) == true @test foldr(-, 1:5) == 3 @test foldr(-, 10, 1:5) == -7 diff --git a/test/sparse/sparse.jl b/test/sparse/sparse.jl index 0b8265ee6642a7..abe93adbbba496 100644 --- a/test/sparse/sparse.jl +++ b/test/sparse/sparse.jl @@ -1494,8 +1494,8 @@ let @test A13024 | B13024 == sparse([1,2,3,4,4,5], [1,2,3,3,4,5], fill(true,6)) @test typeof(A13024 | B13024) == SparseMatrixCSC{Bool,Int} - @test xor(A13024, B13024) == sparse([3,4,4], [3,3,4], fill(true,3), 5, 5) - @test typeof(xor(A13024, B13024)) == SparseMatrixCSC{Bool,Int} + @test A13024 ⊻ B13024 == sparse([3,4,4], [3,3,4], fill(true,3), 5, 5) + @test typeof(A13024 ⊻ B13024) == SparseMatrixCSC{Bool,Int} @test max(A13024, B13024) == sparse([1,2,3,4,4,5], [1,2,3,3,4,5], fill(true,6)) @test typeof(max(A13024, B13024)) == SparseMatrixCSC{Bool,Int}