From df832b73087992d01bcd7d441d6f22cd6621f89a Mon Sep 17 00:00:00 2001 From: Andy Hayden Date: Sun, 1 May 2016 09:45:16 -0700 Subject: [PATCH] Clean up Symbol usage (after symbol deprecation). From comments by stevengj in #15995. --- base/broadcast.jl | 4 ++-- base/dates/arithmetic.jl | 2 +- base/dates/periods.jl | 4 ++-- base/dft.jl | 6 +++--- base/fft/dct.jl | 2 +- base/libuv.jl | 4 ++-- base/multidimensional.jl | 4 ++-- base/sparse/sparsevector.jl | 2 +- base/stream.jl | 2 +- base/threadcall.jl | 2 +- test/ccall.jl | 4 ++-- test/fft.jl | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/base/broadcast.jl b/base/broadcast.jl index 99c80aa3654935..a7dfdd9ce00215 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -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_",string(i)) for i = 1:narrays] body = genbody(nd, narrays, f) @eval let local _F_ @@ -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_",string(i)) for i = 1:narrays] body = genbody(nd, narrays, f) @eval let local _F_ diff --git a/base/dates/arithmetic.jl b/base/dates/arithmetic.jl index 4a94fc13df9116..4f4b19c2ff5c17 100644 --- a/base/dates/arithmetic.jl +++ b/base/dates/arithmetic.jl @@ -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]) @eval begin # GeneralPeriod, AbstractArray{TimeType} ($op){T<:TimeType}(x::AbstractArray{T}, y::GeneralPeriod) = diff --git a/base/dates/periods.jl b/base/dates/periods.jl index 766aa1d50f04b9..a6a991ca6347a0 100644 --- a/base/dates/periods.jl +++ b/base/dates/periods.jl @@ -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) @@ -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) diff --git a/base/dft.jl b/base/dft.jl index b23f10a5b080bc..bc4ea46f26d9b3 100644 --- a/base/dft.jl +++ b/base/dft.jl @@ -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 @@ -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...) @@ -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 diff --git a/base/fft/dct.jl b/base/fft/dct.jl index edd41c3722d159..b41ed8747e11df 100644 --- a/base/fft/dct.jl +++ b/base/fft/dct.jl @@ -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 diff --git a/base/libuv.jl b/base/libuv.jl index 11d649860d1e01..1a01b22cfc0da4 100644 --- a/base/libuv.jl +++ b/base/libuv.jl @@ -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) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index fcdd0b2fc8def1..f442f6a178ee03 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -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)) 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 diff --git a/base/sparse/sparsevector.jl b/base/sparse/sparsevector.jl index 9836432c7e749c..f1ec0f83dcf5bc 100644 --- a/base/sparse/sparsevector.jl +++ b/base/sparse/sparsevector.jl @@ -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 ( diff --git a/base/stream.jl b/base/stream.jl index f48706cb40cb74..4a525e99aa6fab 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -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) diff --git a/base/threadcall.jl b/base/threadcall.jl index 3308d749f2e132..899492d957cc32 100644 --- a/base/threadcall.jl +++ b/base/threadcall.jl @@ -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) diff --git a/test/ccall.jl b/test/ccall.jl index ff250bde120030..df815e9fc5259a 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -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) diff --git a/test/fft.jl b/test/fft.jl index 1883656947dd95..91663c268a6969 100644 --- a/test/fft.jl +++ b/test/fft.jl @@ -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)