Skip to content

Commit a26c7a7

Browse files
committed
Deprecate ~ to !.
1 parent ed6a58d commit a26c7a7

10 files changed

+19
-23
lines changed

base/bitarray.jl

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

11071104
"""
11081105
flipbits!(B::BitArray{N}) -> BitArray{N}
@@ -1692,13 +1689,11 @@ maximum(B::BitArray) = isempty(B) ? throw(ArgumentError("argument must be non-em
16921689
# instead of looping bit-by-bit.
16931690

16941691
map(::typeof(!), A::BitArray) = bit_map!(!, similar(A), A)
1695-
map(::typeof(~), A::BitArray) = map(!, A) # TODO deprecate
16961692
map(::typeof(zero), A::BitArray) = fill!(similar(A), false)
16971693
map(::typeof(one), A::BitArray) = fill!(similar(A), true)
16981694
map(::typeof(identity), A::BitArray) = copy(A)
16991695

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

17031698
map!(::typeof(zero), dest::BitArray, A::BitArray) = fill!(dest, false)
17041699
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
@@ -2887,6 +2887,18 @@ workspace() = error("`workspace()` is discontinued, consider Revise.jl for an al
28872887
@deprecate Ref(x::Ptr) Ref(x, 1)
28882888
@deprecate Ref(x::Ref) x # or perhaps, `convert(Ref, x)`
28892889

2890+
# merge ~ into !
2891+
@deprecate (~)(x::Bool) !x
2892+
@deprecate (~)(n::Integer) !n
2893+
@deprecate (~)(x::BitInteger) !x
2894+
@eval Base.GMP begin
2895+
import Base: ~
2896+
@deprecate (~)(x::BigInt) !x
2897+
end
2898+
@deprecate map(::typeof(~), A::BitArray) map(!, A)
2899+
@deprecate map!(::typeof(~), dest::BitArray, A::BitArray) map(!, dest, A)
2900+
@deprecate broadcast(::typeof(~), B::BitArray) broadcast(!, B)
2901+
28902902
# PR #25184. Use getproperty instead of getindex for Factorizations
28912903
function getindex(F::Factorization, s::Symbol)
28922904
depwarn("`F[:$s]` is deprecated, use `F.$s` instead.", :getindex)

base/exports.jl

-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ export
214214
^,
215215
|,
216216
|>,
217-
~,
218217
:,
219218
=>,
220219
,

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/base/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/base/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)) |

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

0 commit comments

Comments
 (0)