From a9a3076ca7157e8599d908e8ec7549834e77f842 Mon Sep 17 00:00:00 2001
From: "David A. van Leeuwen" <david.vanleeuwen@gmail.com>
Date: Sun, 16 Oct 2016 19:36:08 +0200
Subject: [PATCH 1/3] Deprecate $ for xor() (#18696)

This includes:
 - occurrances of $ (as infix operator) and $= in base
 - occurances of $ in test
 - the definition in the manual
 - the entry in REPL help

This commit does not introduce an alternative,
that will happen in the next commit.
---
 base/arraymath.jl                      |  4 ++--
 base/associative.jl                    |  2 +-
 base/bitarray.jl                       | 22 +++++++++---------
 base/bool.jl                           |  2 +-
 base/broadcast.jl                      |  4 ++--
 base/c.jl                              | 10 ++++----
 base/char.jl                           |  2 +-
 base/combinatorics.jl                  |  2 +-
 base/complex.jl                        |  2 +-
 base/dSFMT.jl                          | 20 ++++++++--------
 base/deprecated.jl                     |  5 +++-
 base/docs/helpdb/Base.jl               |  4 ++--
 base/exports.jl                        |  2 +-
 base/fastmath.jl                       |  2 +-
 base/float.jl                          |  8 +++----
 base/gmp.jl                            |  8 +++----
 base/hashing.jl                        | 18 +++++++--------
 base/hashing2.jl                       |  8 +++----
 base/int.jl                            |  6 ++---
 base/intset.jl                         |  6 ++---
 base/math.jl                           |  6 ++---
 base/operators.jl                      |  8 +++----
 base/promotion.jl                      |  4 ++--
 base/random.jl                         | 22 +++++++++---------
 base/set.jl                            |  2 +-
 base/sparse/sparse.jl                  |  2 +-
 base/sparse/sparsematrix.jl            |  4 ++--
 doc/manual/mathematical-operations.rst | 30 ++++++++++++------------
 test/bigint.jl                         | 12 +++++-----
 test/bitarray.jl                       | 32 +++++++++++++-------------
 test/numbers.jl                        |  8 +++----
 test/operators.jl                      |  2 +-
 test/reduce.jl                         |  8 +++----
 test/sparse/sparse.jl                  |  6 ++---
 34 files changed, 143 insertions(+), 140 deletions(-)

diff --git a/base/arraymath.jl b/base/arraymath.jl
index f6009bd7a89c8..22a6c6db6f17d 100644
--- a/base/arraymath.jl
+++ b/base/arraymath.jl
@@ -66,7 +66,7 @@ promote_array_type{S<:Integer}(::typeof(./), ::Type{S}, ::Type{Bool}, T::Type) =
 promote_array_type{S<:Integer}(::typeof(.\), ::Type{S}, ::Type{Bool}, T::Type) = T
 promote_array_type{S<:Integer}(F, ::Type{S}, ::Type{Bool}, T::Type) = T
 
-for f in (:+, :-, :div, :mod, :&, :|, :$)
+for f in (:+, :-, :div, :mod, :&, :|, :xor)
     @eval ($f)(A::AbstractArray, B::AbstractArray) =
         _elementwise($f, promote_eltype_op($f, A, B), A, B)
 end
@@ -89,7 +89,7 @@ function _elementwise{T}(op, ::Type{T}, A::AbstractArray, B::AbstractArray)
     return F
 end
 
-for f in (:.+, :.-, :.*, :./, :.\, :.^, :.÷, :.%, :.<<, :.>>, :div, :mod, :rem, :&, :|, :$)
+for f in (:.+, :.-, :.*, :./, :.\, :.^, :.÷, :.%, :.<<, :.>>, :div, :mod, :rem, :&, :|, :xor)
     @eval begin
         function ($f){T}(A::Number, B::AbstractArray{T})
             R = promote_op($f, typeof(A), T)
diff --git a/base/associative.jl b/base/associative.jl
index 5de0864871215..67d2944215b7b 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 $= hash(k, hash(v))
+        h = xor(h, hash(k, hash(v)))
     end
     return h
 end
diff --git a/base/bitarray.jl b/base/bitarray.jl
index 34ef888850b20..3c66f16cc4e20 100644
--- a/base/bitarray.jl
+++ b/base/bitarray.jl
@@ -1333,12 +1333,12 @@ function (|)(B::BitArray, x::Bool)
 end
 (|)(x::Bool, B::BitArray) = B | x
 
-function ($)(B::BitArray, x::Bool)
+function xor(B::BitArray, x::Bool)
     x ? ~B : copy(B)
 end
-($)(x::Bool, B::BitArray) = B $ x
+xor(x::Bool, B::BitArray) = xor(B, x)
 
-for f in (:&, :|, :$)
+for f in (:&, :|, :xor)
     @eval begin
         function ($f)(A::BitArray, B::BitArray)
             F = BitArray(promote_shape(size(A),size(B))...)
@@ -2006,10 +2006,10 @@ map!(::typeof(identity), dest::BitArray, A::BitArray) = copy!(dest, A)
 
 for (T, f) in ((:(Union{typeof(&), typeof(*), typeof(min)}), :(&)),
                (:(Union{typeof(|), typeof(max)}),            :(|)),
-               (:(Union{typeof($), typeof(!=)}),             :($)),
+               (:(Union{typeof(xor), typeof(!=)}),           :xor),
                (:(Union{typeof(>=), typeof(^)}),             :((p, q) -> p | ~q)),
                (:(typeof(<=)),                               :((p, q) -> ~p | q)),
-               (:(typeof(==)),                               :((p, q) -> ~(p $ q))),
+               (:(typeof(==)),                               :((p, q) -> ~xor(p, q))),
                (:(typeof(<)),                                :((p, q) -> ~p & q)),
                (:(typeof(>)),                                :((p, q) -> p & ~q)))
     @eval map(::$T, A::BitArray, B::BitArray) = bit_map!($f, similar(A), A, B)
@@ -2058,12 +2058,12 @@ transpose(B::BitVector) = reshape(copy(B), 1, length(B))
 # http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt
 function transpose8x8(x::UInt64)
     y = x
-    t = (y $ (y >>> 7)) & 0x00aa00aa00aa00aa
-    y = y $ t $ (t << 7)
-    t = (y $ (y >>> 14)) & 0x0000cccc0000cccc
-    y = y $ t $ (t << 14)
-    t = (y $ (y >>> 28)) & 0x00000000f0f0f0f0
-    return y $ t $ (t << 28)
+    t = xor(y, y >>> 7) & 0x00aa00aa00aa00aa
+    y = xor(y, t, t << 7)
+    t = xor(y, y >>> 14) & 0x0000cccc0000cccc
+    y = xor(y, t, t << 14)
+    t = xor(y, y >>> 28) & 0x00000000f0f0f0f0
+    return xor(y, t, t << 28)
 end
 
 function form_8x8_chunk(Bc::Vector{UInt64}, i1::Int, i2::Int, m::Int, cgap::Int, cinc::Int, nc::Int, msk8::UInt64)
diff --git a/base/bool.jl b/base/bool.jl
index 82bbf4ec9ec8b..8a524dbb0d29e 100644
--- a/base/bool.jl
+++ b/base/bool.jl
@@ -23,7 +23,7 @@ end
 (~)(x::Bool) = !x
 (&)(x::Bool, y::Bool) = box(Bool,and_int(unbox(Bool,x),unbox(Bool,y)))
 (|)(x::Bool, y::Bool) = box(Bool,or_int(unbox(Bool,x),unbox(Bool,y)))
-($)(x::Bool, y::Bool) = (x!=y)
+xor(x::Bool, y::Bool) = (x!=y)
 
 >>(x::Bool, c::Unsigned) = Int(x) >> c
 <<(x::Bool, c::Unsigned) = Int(x) << c
diff --git a/base/broadcast.jl b/base/broadcast.jl
index 696ba15c08463..bd0d00c5f90d8 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) = ~a $ b
+biteq(a::UInt64, b::UInt64) = xor(~a, b)
 bitlt(a::UInt64, b::UInt64) = ~a & b
-bitneq(a::UInt64, b::UInt64) = a $ b
+bitneq(a::UInt64, b::UInt64) = xor(a, b)
 bitle(a::UInt64, b::UInt64) = ~a | b
 
 .==(A::AbstractArray{Bool}, B::AbstractArray{Bool}) = broadcast_bitarrays(==, biteq, A, B)
diff --git a/base/c.jl b/base/c.jl
index 09367b9709cc5..9b50629ffdec8 100644
--- a/base/c.jl
+++ b/base/c.jl
@@ -187,24 +187,24 @@ function transcode(::Type{UInt16}, src::Vector{UInt8})
                 push!(dst, a)
                 a = b; continue
             elseif a < 0xe0 # 2-byte UTF-8
-                push!(dst, 0x3080 $ (UInt16(a) << 6) $ b)
+                push!(dst, xor(0x3080, UInt16(a) << 6, b))
             elseif i < n # 3/4-byte character
                 c = src[i += 1]
                 if -64 <= (c % Int8) # invalid UTF-8 (non-continuation)
                     push!(dst, a, b)
                     a = c; continue
                 elseif a < 0xf0 # 3-byte UTF-8
-                    push!(dst, 0x2080 $ (UInt16(a) << 12) $ (UInt16(b) << 6) $ c)
+                    push!(dst, xor(0x2080, UInt16(a) << 12, UInt16(b) << 6, c))
                 elseif i < n
                     d = src[i += 1]
                     if -64 <= (d % Int8) # invalid UTF-8 (non-continuation)
                         push!(dst, a, b, c)
                         a = d; continue
                     elseif a == 0xf0 && b < 0x90 # overlong encoding
-                        push!(dst, 0x2080 $ (UInt16(b) << 12) $ (UInt16(c) << 6) $ d)
+                        push!(dst, xor(0x2080, UInt16(b) << 12, UInt16(c) << 6, d))
                     else # 4-byte UTF-8
                         push!(dst, 0xe5b8 + (UInt16(a) << 8) + (UInt16(b) << 2) + (c >> 4),
-                                   0xdc80 $ (UInt16(c & 0xf) << 6) $ d)
+                                   xor(0xdc80, UInt16(c & 0xf) << 6, d))
                     end
                 else # too short
                     push!(dst, a, b, c)
@@ -273,7 +273,7 @@ function transcode(::Type{UInt8}, src::Vector{UInt16})
                 a += 0x2840
                 dst[j += 1] = 0xf0 | ((a >> 8) % UInt8)
                 dst[j += 1] = 0x80 | ((a % UInt8) >> 2)
-                dst[j += 1] = 0xf0 $ ((((a % UInt8) << 4) & 0x3f) $ (b >> 6) % UInt8)
+                dst[j += 1] = xor(0xf0, ((a % UInt8) << 4) & 0x3f, (b >> 6) % UInt8)
                 dst[j += 1] = 0x80 | ((b % UInt8) & 0x3f)
             else
                 dst[j += 1] = 0xe0 | ((a >> 12) % UInt8)
diff --git a/base/char.jl b/base/char.jl
index 58481c6d39c2a..82c88cdd88a69 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(((UInt64(x)+hashchar_seed)<<32) $ UInt64(h))
+hash(x::Char, h::UInt) = hash_uint64(xor((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 cac4b04c3fa9b..103dc68a89144 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] $= true) || return false
+        (0 < a <= n) && (used[a] = xor(used[a], true)) || return false
     end
     true
 end
diff --git a/base/complex.jl b/base/complex.jl
index 161bff0743611..095ab8342cab8 100644
--- a/base/complex.jl
+++ b/base/complex.jl
@@ -162,7 +162,7 @@ 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), h $ hash(imag(z), h_imag) $ hash_0_imag)
+    hash(real(z), xor(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 b0eb6e7d41089..c65c699a5c346 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]   $= src[p]
-        dest[j+1] $= src[p+1]
+        dest[j]   = xor(dest[j],   src[p])
+        dest[j+1] = xor(dest[j+1], src[p+1])
         i += 1
     end
     while i <= N
         j = i*2-1
         p = j + (diff - N)*2
-        dest[j]   $= src[p]
-        dest[j+1] $= src[p+1]
+        dest[j]   = xor(dest[j],   src[p])
+        dest[j+1] = xor(dest[j+1], src[p+1])
         i += 1
     end
-    dest[N*2+1] $= src[N*2+1]
-    dest[N*2+2] $= src[N*2+2]
+    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])
     return dest
 end
 
@@ -148,10 +148,10 @@ function dsfmt_jump_next_state!(mts::Vector{UInt64})
     t1 = mts[a+1]
     L0 = mts[u]
     L1 = mts[u+1]
-    mts[u]   = (t0 << SL1) $ (L1 >> 32) $ (L1 << 32) $ mts[b]
-    mts[u+1] = (t1 << SL1) $ (L0 >> 32) $ (L0 << 32) $ mts[b+1]
-    mts[a]   = (mts[u]   >> SR) $ (mts[u]   & MSK1) $ t0
-    mts[a+1] = (mts[u+1] >> SR) $ (mts[u+1] & MSK2) $ t1
+    mts[u]   = xor(t0 << SL1, L1 >> 32, L1 << 32, mts[b])
+    mts[u+1] = xor(t1 << SL1, L0 >> 32, L0 << 32, mts[b+1])
+    mts[a]   = xor(mts[u]   >> SR, mts[u]   & MSK1, t0)
+    mts[a+1] = xor(mts[u+1] >> SR, mts[u+1] & MSK2, t1)
 
     mts[end] = (mts[end] + 2) % (N*2)
     return mts
diff --git a/base/deprecated.jl b/base/deprecated.jl
index cd65d4e0d92c1..025a3c611e9a0 100644
--- a/base/deprecated.jl
+++ b/base/deprecated.jl
@@ -303,7 +303,7 @@ for (Fun, func) in [(:IdFun, :identity),
                     (:ConjFun, :conj),
                     (:AndFun, :&),
                     (:OrFun, :|),
-                    (:XorFun, :$),
+                    (:XorFun, :xor),
                     (:AddFun, :+),
                     (:DotAddFun, :.+),
                     (:SubFun, :-),
@@ -1022,6 +1022,9 @@ end))
 
 @deprecate ipermutedims(A::AbstractArray,p) permutedims(A, invperm(p))
 
+# 18696
+@deprecate ($) xor
+
 @deprecate is (===)
 
 
diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl
index aa9cb83ba5630..87c3b027313ca 100644
--- a/base/docs/helpdb/Base.jl
+++ b/base/docs/helpdb/Base.jl
@@ -3340,8 +3340,8 @@ Compute the Dawson function (scaled imaginary error function) of `x`, defined by
 dawson
 
 """
-    \$(x, y)
+    xor(x, y)
 
 Bitwise exclusive or.
 """
-Base.:$(x, y)
+Base.xor(x, y)
diff --git a/base/exports.jl b/base/exports.jl
index 5b7757236ef9a..d555bc431a71d 100644
--- a/base/exports.jl
+++ b/base/exports.jl
@@ -205,7 +205,7 @@ export
     !==,
     ≡,
     ≢,
-    $,
+    xor,
     %,
     ÷,
     &,
diff --git a/base/fastmath.jl b/base/fastmath.jl
index fd2edceb0befd..93dd88f3c9ec7 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<y, -1, +1))
     function mod_fast{T<:FloatTypes}(x::T, y::T)
         r = rem(x,y)
-        ifelse((r > 0) $ (y > 0), r+y, r)
+        ifelse(xor(r > 0, y > 0), r+y, r)
     end
 end
 
diff --git a/base/float.jl b/base/float.jl
index 99490d8bdcd45..4191bd29d6c60 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, reinterpret(UInt16,x) $ 0x8000)
+-(x::Float16) = reinterpret(Float16, xor(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 (r > 0) $ (y > 0)
+    elseif xor(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) ? (hx_NaN $ h) : hx(box(UInt64,fptoui(unbox(Float64,abs(x)))), 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::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 fneg $ dneg
+        if xor(fneg, dneg)
             if du > fu
                 fu = min(fumax, du - fu)
                 fneg = !fneg
diff --git a/base/gmp.jl b/base/gmp.jl
index bf0111598e5b0..1d0deb3f8b35d 100644
--- a/base/gmp.jl
+++ b/base/gmp.jl
@@ -4,7 +4,7 @@ module GMP
 
 export BigInt
 
-import Base: *, +, -, /, <, <<, >>, >>>, <=, ==, >, >=, ^, (~), (&), (|), ($),
+import Base: *, +, -, /, <, <<, >>, >>>, <=, ==, >, >=, ^, (~), (&), (|), xor,
              binomial, cmp, convert, div, divrem, factorial, fld, gcd, gcdx, lcm, mod,
              ndigits, promote_rule, rem, show, isqrt, string, powermod,
              sum, trailing_zeros, trailing_ones, count_ones, base, tryparse_internal,
@@ -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
-        (x.size > 0) $ (y > 0) && throw(InexactError()) # catch overflow
+        xor(x.size > 0, y > 0) && throw(InexactError()) # catch overflow
         y
     end
 end
@@ -249,7 +249,7 @@ promote_rule{T<:Integer}(::Type{BigInt}, ::Type{T}) = BigInt
 for (fJ, fC) in ((:+, :add), (:-,:sub), (:*, :mul),
                  (:fld, :fdiv_q), (:div, :tdiv_q), (:mod, :fdiv_r), (:rem, :tdiv_r),
                  (:gcd, :gcd), (:lcm, :lcm),
-                 (:&, :and), (:|, :ior), (:$, :xor))
+                 (:&, :and), (:|, :ior), (:xor, :xor))
     @eval begin
         function ($fJ)(x::BigInt, y::BigInt)
             z = BigInt()
@@ -279,7 +279,7 @@ function invmod(x::BigInt, y::BigInt)
 end
 
 # More efficient commutative operations
-for (fJ, fC) in ((:+, :add), (:*, :mul), (:&, :and), (:|, :ior), (:$, :xor))
+for (fJ, fC) in ((:+, :add), (:*, :mul), (:&, :and), (:|, :ior), (:xor, :xor))
     @eval begin
         function ($fJ)(a::BigInt, b::BigInt, c::BigInt)
             z = BigInt()
diff --git a/base/hashing.jl b/base/hashing.jl
index ab7ed4631b3de..0cda93a3f5ecd 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 =  a $ a >> 24
+    a =  xor(a, a >> 24)
     a =  a + a << 3 + a << 8
-    a =  a $ a >> 14
+    a =  xor(a, a >> 14)
     a =  a + a << 2 + a << 4
-    a =  a $ a >> 28
+    a =  xor(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 =  a $ a >> 31
+    a =  xor(a, a >> 31)
     a =  a * 21
-    a =  a $ a >> 11
+    a =  xor(a, a >> 11)
     a =  a + a << 6
-    a =  a $ a >> 22
+    a =  xor(a, a >> 22)
     return a % UInt32
 end
 
 function hash_32_32(n::UInt32)
     local a::UInt32 = n
     a = a + 0x7ed55d16 + a << 12
-    a = a $ 0xc761c23c $ a >> 19
+    a = xor(a, 0xc761c23c, a >> 19)
     a = a + 0x165667b1 + a << 5
-    a = a + 0xd3a2646c $ a << 9
+    a = a + xor(0xd3a2646c, a << 9)
     a = a + 0xfd7046c5 + a << 3
-    a = a $ 0xb55a4f09 $ a >> 16
+    a = xor(a, 0xb55a4f09, a >> 16)
     return a
 end
 
diff --git a/base/hashing2.jl b/base/hashing2.jl
index 403c5a62e1e93..a8f13341c7cf4 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 = hash_uint((n % UInt) $ h) $ h
+    h = xor(hash_uint(xor(n % UInt, h)), h)
     n = abs(n)
     n >>>= sizeof(UInt) << 3
     while n != 0
-        h = hash_uint((n % UInt) $ h) $ h
+        h = xor(hash_uint(xor(n % UInt, h)), 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 = hash_uint(ifelse(s < 0, -b, b) $ h) $ h
+    h = xor(hash_uint(xor(ifelse(s < 0, -b, b), h)), h)
     for k = 2:abs(s)
-        h = hash_uint(unsafe_load(p, k) $ h) $ h
+        h = xor(hash_uint(xor(unsafe_load(p, k), h)), h)
     end
     return h
 end
diff --git a/base/int.jl b/base/int.jl
index 33836165e1ca0..3d069c8fb81ef 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, x$y)
+copysign(x::Signed, y::Signed)  = flipsign(x, xor(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(x$y) & (d*y!=x))
+    d - (signbit(xor(x,y)) & (d*y!=x))
 end
 
 # cld(x,y) = div(x,y) + ((x>0) == (y>0) && rem(x,y) != 0 ? 1 : 0)
@@ -167,7 +167,7 @@ end
 (~){T<:BitInteger}(x::T)       = box(T,not_int(unbox(T,x)))
 (&){T<:BitInteger}(x::T, y::T) = box(T,and_int(unbox(T,x),unbox(T,y)))
 (|){T<:BitInteger}(x::T, y::T) = box(T, or_int(unbox(T,x),unbox(T,y)))
-($){T<:BitInteger}(x::T, y::T) = box(T,xor_int(unbox(T,x),unbox(T,y)))
+xor{T<:BitInteger}(x::T, y::T) = box(T,xor_int(unbox(T,x),unbox(T,y)))
 
 bswap{T<:Union{Int8,UInt8}}(x::T) = x
 bswap{T<:Union{Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128}}(x::T) =
diff --git a/base/intset.jl b/base/intset.jl
index b512faa9bfcf4..22703a665483b 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] $= (UInt32(1)<<(n&31))
+    s.bits[n>>5 + 1] = xor(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] $= s2.bits[n]
+        s.bits[n] = xor(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 $= s2.fill1s
+    s.fill1s = xor(s.fill1s, s2.fill1s)
     s
 end
 
diff --git a/base/math.jl b/base/math.jl
index 6df96f53d03c5..335b829ff34b7 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 $= xs
+        xu = xor(xu, xs)
         m = leading_zeros(xu)-exponent_bits(T)
         xu <<= m
-        xu $= xs
+        xu = xor(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 = xs $ (xu & sign_mask(T))
+        xu = xor(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 8ab8138714fc8..3ff0583c29131 100644
--- a/base/operators.jl
+++ b/base/operators.jl
@@ -265,7 +265,7 @@ identity(x) = x
 *(x::Number) = x
 (&)(x::Integer) = x
 (|)(x::Integer) = x
-($)(x::Integer) = x
+xor(x::Integer) = x
 
 # 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
@@ -279,7 +279,7 @@ function afoldl(op,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,qs...)
     y
 end
 
-for op in (:+, :*, :&, :|, :$, :min, :max, :kron)
+for op in (:+, :*, :&, :|, :xor, :min, :max, :kron)
     @eval begin
         # note: these definitions must not cause a dispatch loop when +(a,b) is
         # not defined, and must only try to call 2-argument definitions, so
@@ -982,7 +982,7 @@ export
     !=,
     !==,
     ===,
-    $,
+    xor,
     %,
     .%,
     ÷,
@@ -1051,7 +1051,7 @@ export
     transpose,
     ctranspose
 
-import ..this_module: !, !=, $, %, .%, ÷, .÷, &, *, +, -, .!=, .+, .-, .*, ./, .<, .<=, .==, .>,
+import ..this_module: !, !=, xor, %, .%, ÷, .÷, &, *, +, -, .!=, .+, .-, .*, ./, .<, .<=, .==, .>,
     .>=, .\, .^, /, //, <, <:, <<, <=, ==, >, >=, >>, .>>, .<<, >>>,
     <|, |>, \, ^, |, ~, !==, ===, >:, colon, hcat, vcat, hvcat, getindex, setindex!,
     transpose, ctranspose,
diff --git a/base/promotion.jl b/base/promotion.jl
index 0703fc71824d8..2273a3882b50c 100644
--- a/base/promotion.jl
+++ b/base/promotion.jl
@@ -198,7 +198,7 @@ muladd(x::Number, y::Number, z::Number) = muladd(promote(x,y,z)...)
 
 (&)(x::Integer, y::Integer) = (&)(promote(x,y)...)
 (|)(x::Integer, y::Integer) = (|)(promote(x,y)...)
-($)(x::Integer, y::Integer) = ($)(promote(x,y)...)
+xor(x::Integer, y::Integer) = xor(promote(x,y)...)
 
 ==(x::Number, y::Number) = (==)(promote(x,y)...)
 <( x::Real, y::Real)     = (< )(promote(x,y)...)
@@ -253,7 +253,7 @@ muladd{T<:Number}(x::T, y::T, z::T) = x*y+z
 
 (&){T<:Integer}(x::T, y::T) = no_op_err("&", T)
 (|){T<:Integer}(x::T, y::T) = no_op_err("|", T)
-($){T<:Integer}(x::T, y::T) = no_op_err("\$", T)
+xor{T<:Integer}(x::T, y::T) = no_op_err("xor", T)
 
 =={T<:Number}(x::T, y::T) = x === y
  <{T<:Real}(x::T, y::T) = no_op_err("<" , T)
diff --git a/base/random.jl b/base/random.jl
index fffa957242679..e8a91237450ad 100644
--- a/base/random.jl
+++ b/base/random.jl
@@ -324,14 +324,14 @@ rand(r::Union{RandomDevice,MersenneTwister}, ::Type{Float32}) =
 
 function rand(r::MersenneTwister, ::Type{UInt64})
     reserve(r, 2)
-    rand_ui52_raw_inbounds(r) << 32 $ rand_ui52_raw_inbounds(r)
+    xor(rand_ui52_raw_inbounds(r) << 32, rand_ui52_raw_inbounds(r))
 end
 
 function rand(r::MersenneTwister, ::Type{UInt128})
     reserve(r, 3)
-    rand_ui52_raw_inbounds(r) % UInt128 << 96 $
-    rand_ui52_raw_inbounds(r) % UInt128 << 48 $
-    rand_ui52_raw_inbounds(r)
+    xor(rand_ui52_raw_inbounds(r) % UInt128 << 96,
+        rand_ui52_raw_inbounds(r) % UInt128 << 48,
+        rand_ui52_raw_inbounds(r))
 end
 
 rand(r::MersenneTwister, ::Type{Int64})   = reinterpret(Int64,  rand(r, UInt64))
@@ -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 $= u << 26
+        u = xor(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]    $= u << 48
-            A[n-=1] $= u << 36
-            A[n-=1] $= u << 24
-            A[n-=1] $= u << 12
-            n-=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
         end
     end
     if n > 0
         u = rand_ui2x52_raw(r)
         for i = 1:n
-            @inbounds A[i] $= u << 12*i
+            @inbounds A[i] = xor(A[i], u << 12*i)
         end
     end
     A
diff --git a/base/set.jl b/base/set.jl
index 28a8b05e99209..a47a76460a0a4 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 $= hash(x)
+        h = xor(h, hash(x))
     end
     return h
 end
diff --git a/base/sparse/sparse.jl b/base/sparse/sparse.jl
index 1936ca01f4e75..8cd969f4c9095 100644
--- a/base/sparse/sparse.jl
+++ b/base/sparse/sparse.jl
@@ -6,7 +6,7 @@ using Base: ReshapedArray, promote_op, setindex_shape_check, to_shape
 using Base.Sort: Forward
 using Base.LinAlg: AbstractTriangular, PosDefException
 
-import Base: +, -, *, \, &, |, $, .+, .-, .*, ./, .\, .^, .<, .!=, ==
+import Base: +, -, *, \, &, |, xor, .+, .-, .*, ./, .\, .^, .<, .!=, ==
 import Base: A_mul_B!, Ac_mul_B, Ac_mul_B!, At_mul_B, At_mul_B!
 import Base: A_mul_Bc, A_mul_Bt, Ac_mul_Bc, At_mul_Bt
 import Base: At_ldiv_B, Ac_ldiv_B, A_ldiv_B!
diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl
index f1bfb662f567f..b48ad0f731631 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] $= 1) == 1) || return false
+        (0 < k ≤ n) && ((checkspace[k] = xor(checkspace[k], 1)) == 1) || return false
     end
     return true
 end
@@ -1751,7 +1751,7 @@ broadcast_zpreserving{Tv,Ti}(f::Function, A_1::Union{Array,BitArray,Number}, A_2
 
 ## Binary arithmetic and boolean operators
 
-for op in (+, -, min, max, &, |, $)
+for op in (+, -, min, max, &, |, xor)
     body = gen_broadcast_body_sparse(op, true)
     OP = Symbol(string(op))
     @eval begin
diff --git a/doc/manual/mathematical-operations.rst b/doc/manual/mathematical-operations.rst
index c7afc243c7590..d19560db94e7f 100644
--- a/doc/manual/mathematical-operations.rst
+++ b/doc/manual/mathematical-operations.rst
@@ -68,17 +68,17 @@ The following `bitwise
 operators <https://en.wikipedia.org/wiki/Bitwise_operation#Bitwise_operators>`_
 are supported on all primitive integer types:
 
-===========  =========================================================================
-Expression   Name
-===========  =========================================================================
-``~x``       bitwise not
-``x & y``    bitwise and
-``x | y``    bitwise or
-``x $ y``    bitwise xor (exclusive or)
-``x >>> y``  `logical shift <https://en.wikipedia.org/wiki/Logical_shift>`_ right
-``x >> y``   `arithmetic shift <https://en.wikipedia.org/wiki/Arithmetic_shift>`_ right
-``x << y``   logical/arithmetic shift left
-===========  =========================================================================
+===========   =========================================================================
+Expression    Name
+===========   =========================================================================
+``~x``        bitwise not
+``x & y``     bitwise and
+``x | y``     bitwise or
+``xor(x, y)`` bitwise xor (exclusive or)
+``x >>> y``   `logical shift <https://en.wikipedia.org/wiki/Logical_shift>`_ right
+``x >> y``    `arithmetic shift <https://en.wikipedia.org/wiki/Arithmetic_shift>`_ right
+``x << y``    logical/arithmetic shift left
+===========   =========================================================================
 
 Here are some examples with bitwise operators:
 
@@ -93,7 +93,7 @@ Here are some examples with bitwise operators:
     julia> 123 | 234
     251
 
-    julia> 123 $ 234
+    julia> xor(123, 234)
     145
 
     julia> ~UInt32(123)
@@ -122,7 +122,7 @@ equivalent to writing ``x = x + 3``::
 The updating versions of all the binary arithmetic and bitwise operators
 are::
 
-    +=  -=  *=  /=  \=  ÷=  %=  ^=  &=  |=  $=  >>>=  >>=  <<=
+    +=  -=  *=  /=  \=  ÷=  %=  ^=  &=  |=  >>>=  >>=  <<=
 
 
 .. note::
@@ -344,11 +344,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/test/bigint.jl b/test/bigint.jl
index 9a653a6569f82..de5a1a07949fc 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 BigInt(123) $ BigInt(234) == 145
+@test xor(BigInt(123), BigInt(234)) == 145
 
 @test gcd(BigInt(48), BigInt(180)) == 12
 @test lcm(BigInt(48), BigInt(180)) == 720
@@ -199,11 +199,11 @@ g = parse(BigInt,"-1")
 @test *(a, b, c, d, f) == parse(BigInt,"-45258849200337190631492857400003938881995610529251881450243326128168934937055005474972396281351684800")
 @test *(a, b, c, d, f, g) == parse(BigInt,"45258849200337190631492857400003938881995610529251881450243326128168934937055005474972396281351684800")
 
-@test ($)(a, b) == parse(BigInt,"327299")
-@test ($)(a, b, c) == parse(BigInt,"3426495623485904783798472")
-@test ($)(a, b, c, d) == parse(BigInt,"-3426495623485906178489610")
-@test ($)(a, b, c, d, f) == parse(BigInt,"-2413804710837418037418307081437316711364709261074607933698")
-@test ($)(a, b, c, d, f, g) == parse(BigInt,"2413804710837418037418307081437316711364709261074607933697")
+@test xor(a, b) == parse(BigInt,"327299")
+@test xor(a, b, c) == parse(BigInt,"3426495623485904783798472")
+@test xor(a, b, c, d) == parse(BigInt,"-3426495623485906178489610")
+@test xor(a, b, c, d, f) == parse(BigInt,"-2413804710837418037418307081437316711364709261074607933698")
+@test xor(a, b, c, d, f, g) == parse(BigInt,"2413804710837418037418307081437316711364709261074607933697")
 
 @test (&)(a, b) == parse(BigInt,"124")
 @test (&)(a, b, c) == parse(BigInt,"72")
diff --git a/test/bitarray.jl b/test/bitarray.jl
index 06ae7f9b9a4b4..956cf4e5e6920 100644
--- a/test/bitarray.jl
+++ b/test/bitarray.jl
@@ -784,7 +784,7 @@ let b1 = bitrand(n1, n2)
     b2 = bitrand(n1, n2)
     @check_bit_operation (&)(b1, b2)  BitMatrix
     @check_bit_operation (|)(b1, b2)  BitMatrix
-    @check_bit_operation ($)(b1, b2)  BitMatrix
+    @check_bit_operation xor(b1, b2)  BitMatrix
     @check_bit_operation (+)(b1, b2)  Matrix{Int}
     @check_bit_operation (-)(b1, b2)  Matrix{Int}
     @check_bit_operation (.*)(b1, b2) BitMatrix
@@ -815,7 +815,7 @@ end
 let b0 = falses(0)
     @check_bit_operation (&)(b0, b0)  BitVector
     @check_bit_operation (|)(b0, b0)  BitVector
-    @check_bit_operation ($)(b0, b0)  BitVector
+    @check_bit_operation xor(b0, b0)  BitVector
     @check_bit_operation (.*)(b0, b0) BitVector
     @check_bit_operation (*)(b0, b0') Matrix{Int}
 end
@@ -826,7 +826,7 @@ let b1 = bitrand(n1, n2)
     i2 = rand(1:10, n1, n2)
     @check_bit_operation (&)(b1, i2)  Matrix{Int}
     @check_bit_operation (|)(b1, i2)  Matrix{Int}
-    @check_bit_operation ($)(b1, i2)  Matrix{Int}
+    @check_bit_operation xor(b1, i2)  Matrix{Int}
     @check_bit_operation (+)(b1, i2)  Matrix{Int}
     @check_bit_operation (-)(b1, i2)  Matrix{Int}
     @check_bit_operation (.*)(b1, i2) Matrix{Int}
@@ -859,14 +859,14 @@ let b2 = bitrand(n1, n2)
 
     @check_bit_operation (&)(i1, b2)  Matrix{Int}
     @check_bit_operation (|)(i1, b2)  Matrix{Int}
-    @check_bit_operation ($)(i1, b2)  Matrix{Int}
+    @check_bit_operation xor(i1, b2)  Matrix{Int}
     @check_bit_operation (.+)(i1, b2)  Matrix{Int}
     @check_bit_operation (.-)(i1, b2)  Matrix{Int}
     @check_bit_operation (.*)(i1, b2) Matrix{Int}
 
     @check_bit_operation (&)(u1, b2)  Matrix{UInt8}
     @check_bit_operation (|)(u1, b2)  Matrix{UInt8}
-    @check_bit_operation ($)(u1, b2)  Matrix{UInt8}
+    @check_bit_operation xor(u1, b2)  Matrix{UInt8}
     @check_bit_operation (.+)(u1, b2)  Matrix{UInt8}
     @check_bit_operation (.-)(u1, b2)  Matrix{UInt8}
     @check_bit_operation (.*)(u1, b2) Matrix{UInt8}
@@ -941,10 +941,10 @@ let b1 = bitrand(n1, n2)
     @check_bit_operation (|)(b1, false)  BitMatrix
     @check_bit_operation (|)(true, b1)   BitMatrix
     @check_bit_operation (|)(false, b1)  BitMatrix
-    @check_bit_operation ($)(b1, true)   BitMatrix
-    @check_bit_operation ($)(b1, false)  BitMatrix
-    @check_bit_operation ($)(true, b1)   BitMatrix
-    @check_bit_operation ($)(false, b1)  BitMatrix
+    @check_bit_operation xor(b1, true)   BitMatrix
+    @check_bit_operation xor(b1, false)  BitMatrix
+    @check_bit_operation xor(true, b1)   BitMatrix
+    @check_bit_operation xor(false, b1)  BitMatrix
     @check_bit_operation (.+)(b1, true)   Matrix{Int}
     @check_bit_operation (.+)(b1, false)  Matrix{Int}
     @check_bit_operation (.-)(b1, true)   Matrix{Int}
@@ -960,13 +960,13 @@ let b1 = bitrand(n1, n2)
 
     @check_bit_operation (&)(b1, b2)  BitMatrix
     @check_bit_operation (|)(b1, b2)  BitMatrix
-    @check_bit_operation ($)(b1, b2)  BitMatrix
+    @check_bit_operation xor(b1, b2)  BitMatrix
     @check_bit_operation (&)(b2, b1)  BitMatrix
     @check_bit_operation (|)(b2, b1)  BitMatrix
-    @check_bit_operation ($)(b2, b1)  BitMatrix
+    @check_bit_operation xor(b2, b1)  BitMatrix
     @check_bit_operation (&)(b1, i2)  Matrix{Int}
     @check_bit_operation (|)(b1, i2)  Matrix{Int}
-    @check_bit_operation ($)(b1, i2)  Matrix{Int}
+    @check_bit_operation xor(b1, i2)  Matrix{Int}
     @check_bit_operation (.+)(b1, i2)  Matrix{Int}
     @check_bit_operation (.-)(b1, i2)  Matrix{Int}
     @check_bit_operation (.*)(b1, i2) Matrix{Int}
@@ -976,7 +976,7 @@ let b1 = bitrand(n1, n2)
 
     @check_bit_operation (&)(b1, u2)  Matrix{UInt8}
     @check_bit_operation (|)(b1, u2)  Matrix{UInt8}
-    @check_bit_operation ($)(b1, u2)  Matrix{UInt8}
+    @check_bit_operation xor(b1, u2)  Matrix{UInt8}
     @check_bit_operation (.+)(b1, u2)  Matrix{UInt8}
     @check_bit_operation (.-)(b1, u2)  Matrix{UInt8}
     @check_bit_operation (.*)(b1, u2) Matrix{UInt8}
@@ -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((~(b1 >> i)) $ submask, j) == i+1
+        @test findnextnot(xor(~(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($, 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
     @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!($, 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 == 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 a364d6149117b..523732e608522 100644
--- a/test/numbers.jl
+++ b/test/numbers.jl
@@ -26,10 +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
+@test xor(true,  true)  == false
 
 # the bool operator
 @test Bool(false) == false
diff --git a/test/operators.jl b/test/operators.jl
index 864f0a764e49c..35ff0a6ccaf96 100644
--- a/test/operators.jl
+++ b/test/operators.jl
@@ -43,7 +43,7 @@ p = 1=>:foo
 @test p[endof(p)] == p[end] == p[2] == :foo
 
 @test (|)(2) == 2
-@test ($)(2) == 2
+@test xor(2) == 2
 
 # @test ctranspose('a') == 'a' # (c)transpose of Chars no longer supported
 
diff --git a/test/reduce.jl b/test/reduce.jl
index 5d2a691a77829..6f07967553edc 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)-> 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, [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 false true false false]) == true
-@test Base.mapfoldl((x)-> x $ true, |, false, [true false true false false]) == true
+@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 foldr(-, 1:5) == 3
 @test foldr(-, 10, 1:5) == -7
diff --git a/test/sparse/sparse.jl b/test/sparse/sparse.jl
index 72aef1cbe1ef0..aa454ad21f842 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 A13024 $ B13024 == sparse([3,4,4], [3,3,4], fill(true,3), 5, 5)
-    @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 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}
@@ -1503,7 +1503,7 @@ let
     @test min(A13024, B13024) == sparse([1,2,5], [1,2,5], fill(true,3))
     @test typeof(min(A13024, B13024)) == SparseMatrixCSC{Bool,Int}
 
-    for op in (+, -, &, |, $)
+    for op in (+, -, &, |, xor)
         @test op(A13024, B13024) == op(Array(A13024), Array(B13024))
     end
     for op in (max, min)

From 8444b3a18bd4a53ed00492317cc96331a657cc74 Mon Sep 17 00:00:00 2001
From: "David A. van Leeuwen" <david.vanleeuwen@gmail.com>
Date: Fri, 21 Oct 2016 17:06:10 +0200
Subject: [PATCH 2/3] =?UTF-8?q?Add=20=E2=8A=BB=20as=20alternative=20to=20x?=
 =?UTF-8?q?or,=20and=20`=E2=8A=BB=3D`=20as=20alternative=20to=20`$=3D`.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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.
---
 base/associative.jl                    |  2 +-
 base/broadcast.jl                      |  4 ++--
 base/char.jl                           |  2 +-
 base/combinatorics.jl                  |  2 +-
 base/complex.jl                        |  4 ++--
 base/dSFMT.jl                          | 12 +++++-----
 base/deprecated.jl                     |  6 ++++-
 base/docs/helpdb/Base.jl               |  1 +
 base/exports.jl                        |  1 +
 base/fastmath.jl                       |  2 +-
 base/float.jl                          |  8 +++----
 base/gmp.jl                            |  2 +-
 base/hashing.jl                        | 18 +++++++--------
 base/hashing2.jl                       |  8 +++----
 base/int.jl                            |  4 ++--
 base/intset.jl                         |  6 ++---
 base/latex_symbols.jl                  |  1 +
 base/math.jl                           |  6 ++---
 base/operators.jl                      |  5 ++++-
 base/random.jl                         | 16 ++++++-------
 base/set.jl                            |  2 +-
 base/show.jl                           |  2 +-
 base/sparse/sparsematrix.jl            |  2 +-
 doc/manual/mathematical-operations.rst | 31 ++++++++++++++------------
 src/julia-parser.scm                   |  4 ++--
 src/julia-syntax.scm                   |  2 ++
 test/bigint.jl                         |  2 +-
 test/bitarray.jl                       |  6 ++---
 test/numbers.jl                        |  4 ++++
 test/operators.jl                      |  1 +
 test/reduce.jl                         |  8 +++----
 test/sparse/sparse.jl                  |  4 ++--
 32 files changed, 99 insertions(+), 79 deletions(-)

diff --git a/base/associative.jl b/base/associative.jl
index 67d2944215b7b..4baae3832a21e 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 bd0d00c5f90d8..585bbf3ba2a56 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 82c88cdd88a69..79a1b43dec1e3 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 103dc68a89144..c46f80f321a21 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 095ab8342cab8..e101480ab3649 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 c65c699a5c346..5236c8def9cf3 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 025a3c611e9a0..8dbbb86a349b0 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 87c3b027313ca..63925579e22e0 100644
--- a/base/docs/helpdb/Base.jl
+++ b/base/docs/helpdb/Base.jl
@@ -3341,6 +3341,7 @@ dawson
 
 """
     xor(x, y)
+    ⊻(x, y)
 
 Bitwise exclusive or.
 """
diff --git a/base/exports.jl b/base/exports.jl
index d555bc431a71d..65c8768280371 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 93dd88f3c9ec7..bce8637b7fa40 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<y, -1, +1))
     function mod_fast{T<:FloatTypes}(x::T, y::T)
         r = rem(x,y)
-        ifelse(xor(r > 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 4191bd29d6c60..b89ec91e7c909 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 1d0deb3f8b35d..6da4d33af4d49 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 0cda93a3f5ecd..8e83b21d8ecf3 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 a8f13341c7cf4..23ac5de0b8225 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 3d069c8fb81ef..3ee0b62e4b59f 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 22703a665483b..2200c73d6ca5b 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 86e88a950b4b2..ffa122464446e 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 335b829ff34b7..6fba129a1622f 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 3ff0583c29131..5dfa0162d020d 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 e8a91237450ad..fce69c2436b87 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 a47a76460a0a4..3fc0c9045e4b0 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 1b76b80313cef..2101c478e0e0a 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 b48ad0f731631..4a24f4464dc90 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 d19560db94e7f..0c2f14bbec23e 100644
--- a/doc/manual/mathematical-operations.rst
+++ b/doc/manual/mathematical-operations.rst
@@ -68,17 +68,17 @@ The following `bitwise
 operators <https://en.wikipedia.org/wiki/Bitwise_operation#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 <https://en.wikipedia.org/wiki/Logical_shift>`_ right
-``x >> y``    `arithmetic shift <https://en.wikipedia.org/wiki/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 <https://en.wikipedia.org/wiki/Logical_shift>`_ right
+``x >> y``   `arithmetic shift <https://en.wikipedia.org/wiki/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 63ccf0394cf59..5ac6dc5a65235 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 31e03d7f59549..f67f783d682f6 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 de5a1a07949fc..d6393bdabe225 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 956cf4e5e6920..c53202e8ec91d 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 523732e608522..25be592ecf434 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 35ff0a6ccaf96..622afc9fa14df 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 6f07967553edc..f1a8f3d41c9ef 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 aa454ad21f842..ef920c0af24ce 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}

From e24df226b73b977009f5374276f635028751dd8f Mon Sep 17 00:00:00 2001
From: "David A. van Leeuwen" <david.vanleeuwen@gmail.com>
Date: Thu, 10 Nov 2016 14:46:33 +0100
Subject: [PATCH 3/3] Add deprecation comment in show.jl and deprecation item
 in NEWS.md

---
 NEWS.md      | 2 ++
 base/show.jl | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/NEWS.md b/NEWS.md
index baa5f0ee72e17..4d9b092e8a009 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -68,6 +68,8 @@ Deprecated or removed
 
   * `num` and `den` have been deprecated in favor of `numerator` and `denominator` respectively ([#19233]).
 
+  * infix operator `$` has been deprecated in favor of infix `⊻` or function `xor()` ([#18977]).
+
 Julia v0.5.0 Release Notes
 ==========================
 
diff --git a/base/show.jl b/base/show.jl
index 2101c478e0e0a..db23b39ab4577 100644
--- a/base/show.jl
+++ b/base/show.jl
@@ -449,7 +449,7 @@ const uni_ops = Set{Symbol}([:(+), :(-), :(!), :(¬), :(~), :(<:), :(>:), :(√)
 const expr_infix_wide = Set{Symbol}([
     :(=), :(+=), :(-=), :(*=), :(/=), :(\=), :(^=), :(&=), :(|=), :(÷=), :(%=), :(>>>=), :(>>=), :(<<=),
     :(.=), :(.+=), :(.-=), :(.*=), :(./=), :(.\=), :(.^=), :(.&=), :(.|=), :(.÷=), :(.%=), :(.>>>=), :(.>>=), :(.<<=),
-    :(&&), :(||), :(<:), :(=>), :($=), :(⊻=)])
+    :(&&), :(||), :(<:), :(=>), :($=), :(⊻=)]) # `$=` should be removed after deprecation is removed, issue #18977
 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)