Skip to content

Commit bef7f9e

Browse files
committed
Deprecate ~ to !.
1 parent 27d22b6 commit bef7f9e

9 files changed

+19
-20
lines changed

base/bitarray.jl

-3
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,6 @@ function broadcast(::typeof(!), B::BitArray)
11001100
end
11011101
return C
11021102
end
1103-
broadcast(::typeof(~), B::BitArray) = broadcast(!, B) # TODO deprecate
11041103

11051104

11061105

@@ -1692,13 +1691,11 @@ maximum(B::BitArray) = isempty(B) ? throw(ArgumentError("argument must be non-em
16921691
# instead of looping bit-by-bit.
16931692

16941693
map(::typeof(!), A::BitArray) = bit_map!(!, similar(A), A)
1695-
map(::typeof(~), A::BitArray) = map(!, A) # TODO deprecate
16961694
map(::typeof(zero), A::BitArray) = fill!(similar(A), false)
16971695
map(::typeof(one), A::BitArray) = fill!(similar(A), true)
16981696
map(::typeof(identity), A::BitArray) = copy(A)
16991697

17001698
map!(::typeof(!), dest::BitArray, A::BitArray) = bit_map!(!, dest, A)
1701-
map!(::typeof(~), dest::BitArray, A::BitArray) = map(!, dest, A) # TODO deprecate
17021699

17031700
map!(::typeof(zero), dest::BitArray, A::BitArray) = fill!(dest, false)
17041701
map!(::typeof(one), dest::BitArray, A::BitArray) = fill!(dest, true)

base/bool.jl

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ function !(x::Bool)
3232
return not_int(x)
3333
end
3434

35-
(~)(x::Bool) = !x
3635
(&)(x::Bool, y::Bool) = and_int(x, y)
3736
(|)(x::Bool, y::Bool) = or_int(x, y)
3837

base/deprecated.jl

+12
Original file line numberDiff line numberDiff line change
@@ -3804,6 +3804,18 @@ workspace() = error("`workspace()` is discontinued, consider Revise.jl for an al
38043804
@deprecate Ref(x::Ptr) Ref(x, 1)
38053805
@deprecate Ref(x::Ref) x # or perhaps, `convert(Ref, x)`
38063806

3807+
# merge ~ into !
3808+
@deprecate map(::typeof(~), A::BitArray) map(!, A)
3809+
@deprecate map!(::typeof(~), dest::BitArray, A::BitArray) map(!, dest, A)
3810+
@deprecate broadcast(::typeof(~), B::BitArray) broadcast(!, B)
3811+
@deprecate (~)(x::Bool) !x
3812+
@deprecate (~)(n::Integer) !n
3813+
@deprecate (~)(x::BitInteger) !x
3814+
@eval Base.GMP begin
3815+
import Base: ~
3816+
@deprecate (~)(x::BigInt) !x
3817+
end
3818+
38073819
# PR #25184. Use getproperty instead of getindex for Factorizations
38083820
function getindex(F::Factorization, s::Symbol)
38093821
depwarn("`F[:$s]` is deprecated, use `F.$s` instead.", :getindex)

base/gmp.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module GMP
44

55
export BigInt
66

7-
import Base: *, +, -, /, <, <<, >>, >>>, <=, ==, >, >=, ^, (~), (!), (&), (|), xor,
7+
import Base: *, +, -, /, <, <<, >>, >>>, <=, ==, >, >=, ^, (!), (&), (|), xor,
88
binomial, cmp, convert, div, divrem, factorial, fld, gcd, gcdx, lcm, mod,
99
ndigits, promote_rule, rem, show, isqrt, string, powermod,
1010
sum, trailing_zeros, trailing_ones, count_ones, base, tryparse_internal,
@@ -467,7 +467,6 @@ end
467467
# unary ops
468468
(-)(x::BigInt) = MPZ.neg(x)
469469
(!)(x::BigInt) = MPZ.com(x)
470-
(~)(x::BigInt) = !x
471470

472471
<<(x::BigInt, c::UInt) = c == 0 ? x : MPZ.mul_2exp(x, c)
473472
>>(x::BigInt, c::UInt) = c == 0 ? x : MPZ.fdiv_q_2exp(x, c)

base/int.jl

-7
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ abs(x::Unsigned) = x
133133
abs(x::Signed) = flipsign(x,x)
134134

135135
!(n::Integer) = -n-1
136-
~(n::Integer) = !n
137136

138137
unsigned(x::BitSigned) = reinterpret(typeof(convert(Unsigned, zero(x))), x)
139138
unsigned(x::Bool) = convert(Unsigned, x)
@@ -270,12 +269,6 @@ false
270269
```
271270
"""
272271
(!)(x::BitInteger) = not_int(x)
273-
"""
274-
~(x)
275-
276-
Bitwise not.
277-
"""
278-
(~)(x::BitInteger) = !x
279272

280273
"""
281274
&(x, y)

doc/src/manual/mathematical-operations.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ are supported on all primitive integer types:
5555

5656
| Expression | Name |
5757
|:---------- |:------------------------------------------------------------------------ |
58-
| `~x` | bitwise not |
58+
| `!x` | bitwise not |
5959
| `x & y` | bitwise and |
6060
| `x \| y` | bitwise or |
6161
| `x ⊻ y` | bitwise xor (exclusive or) |
@@ -66,7 +66,7 @@ are supported on all primitive integer types:
6666
Here are some examples with bitwise operators:
6767

6868
```jldoctest
69-
julia> ~123
69+
julia> !123
7070
-124
7171
7272
julia> 123 & 234
@@ -81,10 +81,10 @@ julia> 123 ⊻ 234
8181
julia> xor(123, 234)
8282
145
8383
84-
julia> ~UInt32(123)
84+
julia> !UInt32(123)
8585
0xffffff84
8686
87-
julia> ~UInt8(123)
87+
julia> !UInt8(123)
8888
0x84
8989
```
9090

doc/src/manual/noteworthy-differences.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ For users coming to Julia from R, these are some noteworthy differences:
247247
leading 0s. For example, `0x0` and `0x00` have type [`UInt8`](@ref), `0x000` and `0x0000` have type
248248
[`UInt16`](@ref), then literals with 5 to 8 hex digits have type `UInt32`, 9 to 16 hex digits type
249249
`UInt64` and 17 to 32 hex digits type `UInt128`. This needs to be taken into account when defining
250-
hexadecimal masks, for example `~0xf == 0xf0` is very different from `~0x000f == 0xfff0`. 64 bit `Float64`
250+
hexadecimal masks, for example `!0xf == 0xf0` is very different from `!0x000f == 0xfff0`. 64 bit `Float64`
251251
and 32 bit [`Float32`](@ref) bit literals are expressed as `1.0` and `1.0f0` respectively. Floating point
252252
literals are rounded (and not promoted to the `BigFloat` type) if they can not be exactly represented.
253253
Floating point literals are closer in behavior to C/C++. Octal (prefixed with `0o`) and binary

doc/src/stdlib/math.md

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ Base.:(<=)
4444
Base.:(>)
4545
Base.:(>=)
4646
Base.cmp
47-
Base.:(~)
4847
Base.:(&)
4948
Base.:(|)
5049
Base.xor

doc/src/stdlib/punctuation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Extended documentation for mathematical symbols & functions is [here](@ref math-
2020
| `` | bitwise xor operator |
2121
| `*` | multiply, or matrix multiply |
2222
| `()` | the empty tuple |
23-
| `~` | bitwise not operator |
23+
| `!` | bitwise not operator |
2424
| `\` | backslash operator |
2525
| `'` | complex transpose operator Aᴴ |
2626
| `a[]` | array indexing (calling [`getindex`](@ref) or [`setindex!`](@ref)) |

0 commit comments

Comments
 (0)