Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate symbol (to Symbol) #16154

Merged
merged 3 commits into from
May 2, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clean up Symbol usage (after symbol deprecation).
From comments by stevengj in #15995.
  • Loading branch information
hayd committed May 1, 2016
commit a9df7e9e6306ccca3bb508692cde83dd63125e3a
4 changes: 2 additions & 2 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function gen_broadcast_body_iter_tobitarray(nd::Int, narrays::Int, f)
end

function gen_broadcast_function(genbody::Function, nd::Int, narrays::Int, f)
As = [Symbol("A_"*string(i)) for i = 1:narrays]
As = [Symbol("A_",i) for i = 1:narrays]
body = genbody(nd, narrays, f)
@eval let
local _F_
Expand All @@ -179,7 +179,7 @@ function gen_broadcast_function(genbody::Function, nd::Int, narrays::Int, f)
end

function gen_broadcast_function_tobitarray(genbody::Function, nd::Int, narrays::Int, f)
As = [Symbol("A_"*string(i)) for i = 1:narrays]
As = [Symbol("A_",i) for i = 1:narrays]
body = genbody(nd, narrays, f)
@eval let
local _F_
Expand Down
2 changes: 1 addition & 1 deletion base/dates/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ end
(-)(y::Period,x::TimeType) = x - y

for op in (:.+, :.-)
op_ = Symbol(string(op)[2:end])
op_ = Symbol(string(op)[2])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should really not be combined with renaming

Copy link
Member Author

@hayd hayd May 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the second, cleanup, commit.

Edit: That is, the right hand side of this line diff is in the second commit (removing :end). The symbol -> Symbol is in the first commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are multi character dot operators that this loop may want to be extended to, I think this change is unnecessary and could make this bug prone later

@eval begin
# GeneralPeriod, AbstractArray{TimeType}
($op){T<:TimeType}(x::AbstractArray{T}, y::GeneralPeriod) =
Expand Down
4 changes: 2 additions & 2 deletions base/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ for (op,Ty,Tz) in ((:.*,Real,:P),
(:.%,:P,:P),
(:mod,:P,:P))
sop = string(op)
op_ = sop[1] == '.' ? Symbol(sop[2:end]) : op
op_ = sop[1] == '.' ? Symbol(sop[2]) : op
@eval begin
function ($op){P<:Period}(X::StridedArray{P},y::$Ty)
Z = similar(X, $Tz)
Expand Down Expand Up @@ -234,7 +234,7 @@ GeneralPeriod = Union{Period,CompoundPeriod}
(+){P<:GeneralPeriod}(x::StridedArray{P}) = x

for op in (:.+, :.-)
op_ = Symbol(string(op)[2:end])
op_ = Symbol(string(op)[2])
@eval begin
function ($op){P<:GeneralPeriod}(X::StridedArray{P},y::GeneralPeriod)
Z = similar(X, CompoundPeriod)
Expand Down
6 changes: 3 additions & 3 deletions base/dft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ complexfloat{T<:Real}(x::AbstractArray{T}) = copy!(Array(typeof(complex(float(on
# implementations only need to provide plan_X(x, region)
# for X in (:fft, :bfft, ...):
for f in (:fft, :bfft, :ifft, :fft!, :bfft!, :ifft!, :rfft)
pf = Symbol(string("plan_", f))
pf = Symbol("plan_", f)
@eval begin
$f(x::AbstractArray) = $pf(x) * x
$f(x::AbstractArray, region) = $pf(x, region) * x
Expand Down Expand Up @@ -179,7 +179,7 @@ bfft!
# promote to a complex floating-point type (out-of-place only),
# so implementations only need Complex{Float} methods
for f in (:fft, :bfft, :ifft)
pf = Symbol(string("plan_", f))
pf = Symbol("plan_", f)
@eval begin
$f{T<:Real}(x::AbstractArray{T}, region=1:ndims(x)) = $f(complexfloat(x), region)
$pf{T<:Real}(x::AbstractArray{T}, region; kws...) = $pf(complexfloat(x), region; kws...)
Expand Down Expand Up @@ -264,7 +264,7 @@ A_mul_B!(y::AbstractArray, p::ScaledPlan, x::AbstractArray) =
# or odd).

for f in (:brfft, :irfft)
pf = Symbol(string("plan_", f))
pf = Symbol("plan_", f)
@eval begin
$f(x::AbstractArray, d::Integer) = $pf(x, d) * x
$f(x::AbstractArray, d::Integer, region) = $pf(x, d, region) * x
Expand Down
2 changes: 1 addition & 1 deletion base/fft/dct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function plan_inv{T,K,inplace}(p::DCTPlan{T,K,inplace})
end

for f in (:dct, :dct!, :idct, :idct!)
pf = Symbol(string("plan_", f))
pf = Symbol("plan_", f)
@eval begin
$f{T<:fftwNumber}(x::AbstractArray{T}) = $pf(x) * x
$f{T<:fftwNumber}(x::AbstractArray{T}, region) = $pf(x, region) * x
Expand Down
4 changes: 2 additions & 2 deletions base/libuv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ function uv_sizeof_req(req)
end

for h in uv_handle_types
@eval const $(Symbol("_sizeof_"*lowercase(string(h)))) = uv_sizeof_handle($h)
@eval const $(Symbol("_sizeof_",lowercase(string(h)))) = uv_sizeof_handle($h)
end
for r in uv_req_types
@eval const $(Symbol("_sizeof_"*lowercase(string(r)))) = uv_sizeof_req($r)
@eval const $(Symbol("_sizeof_",lowercase(string(r)))) = uv_sizeof_req($r)
end

uv_handle_data(handle) = ccall(:jl_uv_handle_data,Ptr{Void},(Ptr{Void},),handle)
Expand Down
4 changes: 2 additions & 2 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,14 @@ end
for T in indexes.parameters
T <: CartesianIndex ? (M += length(T)) : (M += 1)
end
index_length_expr = index <: Colon ? Symbol(string("Istride_", N+1)) : :(length(index))
index_length_expr = index <: Colon ? Symbol("Istride_", N+1) : :(length(index))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah damn, this'll probably fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also best not to at-notify users in commit messages, otherwise every time this gets rebased they will get a notification

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know, will change the message when I rebase. Er, why is this "outdated" already?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it back, the above should work. Do you want me to amend the commit message (to remove the mistyped stevengj's at handle)?

quote
Cartesian.@nexprs $N d->(I_d = indexes[d])
dimlengths = Cartesian.@ncall $N index_lengths_dim V.parent length(V.indexes)-N+1 I
Istride_1 = 1 # strides of the indexes to merge
Cartesian.@nexprs $N d->(Istride_{d+1} = Istride_d*dimlengths[d])
idx_len = $(index_length_expr)
if idx_len < 0.1*$(Symbol(string("Istride_", N+1))) # this has not been carefully tuned
if idx_len < 0.1*$(Symbol("Istride_", N+1)) # this has not been carefully tuned
return merge_indexes_div(V, indexes, index, dimlengths)
end
Cartesian.@nexprs $N d->(counter_d = 1) # counter_0 is the linear index
Expand Down
2 changes: 1 addition & 1 deletion base/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ end
for isunittri in (true, false), islowertri in (true, false)
unitstr = isunittri ? "Unit" : ""
halfstr = islowertri ? "Lower" : "Upper"
tritype = :(Base.LinAlg.$(Symbol(string(unitstr, halfstr, "Triangular"))))
tritype = :(Base.LinAlg.$(Symbol(unitstr, halfstr, "Triangular")))

# build out-of-place left-division operations
for (istrans, func, ipfunc) in (
Expand Down
2 changes: 1 addition & 1 deletion base/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ _fd(x::IOStream) = RawFD(fd(x))
ccall(:jl_uv_handle,Ptr{Void},(Ptr{Void},),x.handle))

for (x,writable,unix_fd,c_symbol) in ((:STDIN,false,0,:jl_uv_stdin),(:STDOUT,true,1,:jl_uv_stdout),(:STDERR,true,2,:jl_uv_stderr))
f = Symbol("redirect_"*lowercase(string(x)))
f = Symbol("redirect_",lowercase(string(x)))
_f = Symbol("_",f)
@eval begin
function ($_f)(stream)
Expand Down
2 changes: 1 addition & 1 deletion base/threadcall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ macro threadcall(f, rettype, argtypes, argvals...)
body = wrapper.args[2].args
args = Symbol[]
for (i,T) in enumerate(argtypes)
arg = Symbol("arg$i")
arg = Symbol("arg", i)
push!(body, :($arg = unsafe_load(convert(Ptr{$T}, p))))
push!(body, :(p += sizeof($T)))
push!(args, arg)
Expand Down
4 changes: 2 additions & 2 deletions test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ s1 = Struct1(352.39422f23, 19.287577)

for (t,v) in ((Complex{Int32},:ci32),(Complex{Int64},:ci64),
(Complex64,:cf32),(Complex128,:cf64),(Struct1,:s1))
fname = Symbol("foo"*string(v))
fname1 = Symbol("foo1"*string(v))
fname = Symbol("foo",v)
fname1 = Symbol("foo1",v)
@eval begin
verbose && println($t)
a = copy($v)
Expand Down
2 changes: 1 addition & 1 deletion test/fft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ true_fftd3_m3d[:,:,2] = -15
# use invoke to force usage of CTPlan versions even if FFTW is present
for A in (Array,SubArray)
for f in (:fft,:ifft,:plan_fft,:plan_ifft)
f_ = Symbol(string(f, "_"))
f_ = Symbol(f, "_")
@eval begin
$f_{T,N}(x::$A{T,N}) = invoke($f, Tuple{AbstractArray{T,N}}, x)
$f_{T,N,R}(x::$A{T,N},r::R) = invoke($f,Tuple{AbstractArray{T,N},R},x,r)
Expand Down