Skip to content

Commit ce94dff

Browse files
committed
Add ⊻ as alternative to xor, and ⊻= as alternative to $=.
Please note that `⊻=` is in the add-dots group in the parser, preparing for `.⊻=`. However, this commit does not implement `.⊻` yet, this should happen in a separate commit with `.&` and `.|` together.
1 parent 5e853bb commit ce94dff

33 files changed

+100
-80
lines changed

base/associative.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ const hasha_seed = UInt === UInt64 ? 0x6d35bb51952d5539 : 0x952d5539
251251
function hash(a::Associative, h::UInt)
252252
h = hash(hasha_seed, h)
253253
for (k,v) in a
254-
h = xor(h, hash(k, hash(v)))
254+
h ⊻= hash(k, hash(v))
255255
end
256256
return h
257257
end

base/bitarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,7 @@ map!(f::typeof(max), dest::BitArray, A::BitArray, B::BitArray) = map!(|, dest, A
20102010
map!(f::typeof(!=), dest::BitArray, A::BitArray, B::BitArray) = map!(xor, dest, A, B)
20112011
map!(f::Union{typeof(>=), typeof(^)}, dest::BitArray, A::BitArray, B::BitArray) = map!(BitChunkFunctor((p, q) -> p | ~q), dest, A, B)
20122012
map!(f::typeof(<=), dest::BitArray, A::BitArray, B::BitArray) = map!(BitChunkFunctor((p, q) -> ~p | q), dest, A, B)
2013-
map!(f::typeof(==), dest::BitArray, A::BitArray, B::BitArray) = map!(BitChunkFunctor((p, q) -> ~xor(p, q)), dest, A, B)
2013+
map!(f::typeof(==), dest::BitArray, A::BitArray, B::BitArray) = map!(BitChunkFunctor((p, q) -> ~(p q)), dest, A, B)
20142014
map!(f::typeof(<), dest::BitArray, A::BitArray, B::BitArray) = map!(BitChunkFunctor((p, q) -> ~p & q), dest, A, B)
20152015
map!(f::typeof(>), dest::BitArray, A::BitArray, B::BitArray) = map!(BitChunkFunctor((p, q) -> p & ~q), dest, A, B)
20162016

base/broadcast.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,9 @@ function broadcast_bitarrays(scalarf, bitf, A::AbstractArray{Bool}, B::AbstractA
472472
return F
473473
end
474474

475-
biteq(a::UInt64, b::UInt64) = xor(~a, b)
475+
biteq(a::UInt64, b::UInt64) = ~a b
476476
bitlt(a::UInt64, b::UInt64) = ~a & b
477-
bitneq(a::UInt64, b::UInt64) = xor(a, b)
477+
bitneq(a::UInt64, b::UInt64) = a b
478478
bitle(a::UInt64, b::UInt64) = ~a | b
479479

480480
.==(A::AbstractArray{Bool}, B::AbstractArray{Bool}) = broadcast_bitarrays(==, biteq, A, B)

base/char.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ in(x::Char, y::Char) = x == y
3333
isless(x::Char, y::Char) = UInt32(x) < UInt32(y)
3434

3535
const hashchar_seed = 0xd4d64234
36-
hash(x::Char, h::UInt) = hash_uint64(xor((UInt64(x)+hashchar_seed)<<32, UInt64(h)))
36+
hash(x::Char, h::UInt) = hash_uint64(((UInt64(x)+hashchar_seed)<<32) UInt64(h))
3737

3838
-(x::Char, y::Char) = Int(x) - Int(y)
3939
-(x::Char, y::Integer) = Char(Int32(x) - Int32(y))

base/combinatorics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function isperm(A)
7373
n = length(A)
7474
used = falses(n)
7575
for a in A
76-
(0 < a <= n) && (used[a] = xor(used[a], true)) || return false
76+
(0 < a <= n) && (used[a] ⊻= true) || return false
7777
end
7878
true
7979
end

base/complex.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ const hash_0_imag = hash(0, h_imag)
126126

127127
function hash(z::Complex, h::UInt)
128128
# TODO: with default argument specialization, this would be better:
129-
# hash(real(z), h $ hash(imag(z), h $ h_imag) $ hash(0, h $ h_imag))
130-
hash(real(z), xor(h, hash(imag(z), h_imag), hash_0_imag))
129+
# hash(real(z), h hash(imag(z), h h_imag) hash(0, h h_imag))
130+
hash(real(z), h hash(imag(z), h_imag) hash_0_imag)
131131
end
132132

133133
## generic functions of complex numbers ##

base/dSFMT.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,19 @@ function dsfmt_jump_add!(dest::Vector{UInt64}, src::Vector{UInt64})
115115
while i <= N-diff
116116
j = i*2-1
117117
p = j + diff*2
118-
dest[j] = xor(dest[j], src[p])
119-
dest[j+1] = xor(dest[j+1], src[p+1])
118+
dest[j] ⊻= src[p]
119+
dest[j+1] ⊻= src[p+1]
120120
i += 1
121121
end
122122
while i <= N
123123
j = i*2-1
124124
p = j + (diff - N)*2
125-
dest[j] = xor(dest[j], src[p])
126-
dest[j+1] = xor(dest[j+1], src[p+1])
125+
dest[j] ⊻= src[p]
126+
dest[j+1] ⊻= src[p+1]
127127
i += 1
128128
end
129-
dest[N*2+1] = xor(dest[N*2+1], src[N*2+1])
130-
dest[N*2+2] = xor(dest[N*2+2], src[N*2+2])
129+
dest[N*2+1] ⊻= src[N*2+1]
130+
dest[N*2+2] ⊻= src[N*2+2]
131131
return dest
132132
end
133133

base/deprecated.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,11 @@ end))
10221022
@deprecate ipermutedims(A::AbstractArray,p) permutedims(A, invperm(p))
10231023

10241024
# 18696
1025-
@deprecate ($) xor
1025+
function ($)(x, y)
1026+
depwarn("`x \$ y` is deprecated. use `xor(x, y)` or `x ⊻ y` instead.", :$)
1027+
xor(x, y)
1028+
end
1029+
export $
10261030

10271031
@deprecate is (===)
10281032

base/docs/helpdb/Base.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3386,6 +3386,7 @@ dawson
33863386

33873387
"""
33883388
xor(x, y)
3389+
⊻(x, y)
33893390
33903391
Bitwise exclusive or.
33913392
"""

base/exports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export
206206
,
207207
,
208208
xor,
209+
,
209210
%,
210211
÷,
211212
&,

0 commit comments

Comments
 (0)