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

deprecated symbol(x...) becomes Symbol(x...) #15995

Closed
wants to merge 10 commits into from
4 changes: 2 additions & 2 deletions base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function hist_from_file(hp, file)
m = match(r"^#\s*(\w+)\s*:\s*(.*?)\s*$", line)
m === nothing && break
if m.captures[1] == "mode"
mode = symbol(m.captures[2])
mode = Symbol(m.captures[2])
end
line = hist_getline(file)
countlines += 1
Expand Down Expand Up @@ -731,7 +731,7 @@ function setup_interface(repl::LineEditREPL; hascolor = repl.hascolor, extra_rep
# and pass into Base.repl_cmd for processing (handles `ls` and `cd`
# special)
on_done = respond(repl, julia_prompt) do line
Expr(:call, :(Base.repl_cmd), macroexpand(Expr(:macrocall, symbol("@cmd"),line)), outstream(repl))
Expr(:call, :(Base.repl_cmd), macroexpand(Expr(:macrocall, Symbol("@cmd"),line)), outstream(repl))
end)


Expand Down
6 changes: 3 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -968,11 +968,11 @@ end
exprs = Expr[:(ind = ind-1)]
for i = 1:N-1
push!(exprs,:(ind2 = div(ind,dims[$i])))
push!(exprs,Expr(:(=),symbol(:s,i),:(ind-dims[$i]*ind2+1)))
push!(exprs,Expr(:(=),Symbol(:s,i),:(ind-dims[$i]*ind2+1)))
push!(exprs,:(ind=ind2))
end
push!(exprs,Expr(:(=),symbol(:s,N),:(ind+1)))
Expr(:block,meta,exprs...,Expr(:tuple,[symbol(:s,i) for i=1:N]...))
push!(exprs,Expr(:(=),Symbol(:s,N),:(ind+1)))
Expr(:block,meta,exprs...,Expr(:tuple,[Symbol(:s,i) for i=1:N]...))
end

# TODO in v0.5: either deprecate line 1 or add line 2
Expand Down
4 changes: 2 additions & 2 deletions base/atomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ for typ in atomictypes
end
for rmwop in [:xchg, :add, :sub, :and, :nand, :or, :xor, :max, :min]
rmw = string(rmwop)
fn = symbol("atomic_", rmw, "!")
fn = Symbol("atomic_", rmw, "!")
if (rmw == "max" || rmw == "min") && typ <: Unsigned
# LLVM distinguishes signedness in the operation, not the integer type.
rmw = "u" * rmw
Expand Down Expand Up @@ -321,7 +321,7 @@ end
const opnames = Dict{Symbol, Symbol}(:+ => :add, :- => :sub)
for op in [:+, :-, :max, :min]
opname = get(opnames, op, op)
@eval function $(symbol("atomic_", opname, "!")){T<:FloatTypes}(var::Atomic{T}, val::T)
@eval function $(Symbol("atomic_", opname, "!")){T<:FloatTypes}(var::Atomic{T}, val::T)
IT = inttype(T)
old = var[]
while true
Expand Down
4 changes: 2 additions & 2 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,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]
Copy link
Member

Choose a reason for hiding this comment

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

Should probably be Symbol("A_", i)

body = genbody(nd, narrays, f)
@eval let
local _F_
Expand All @@ -180,7 +180,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_
Expand Down
6 changes: 3 additions & 3 deletions base/cartesian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function inlineanonymous(ex::Expr, val)
end

# Given :i and 3, this generates :i_3
inlineanonymous(base::Symbol, ext) = symbol(base,"_",string(ext))
inlineanonymous(base::Symbol, ext) = Symbol(base,"_",string(ext))

# Replace a symbol by a value or a "coded" symbol
# E.g., for d = 3,
Expand All @@ -277,7 +277,7 @@ lreplace(ex, sym::Symbol, val) = lreplace!(copy(ex), LReplace(sym, val))

function lreplace!(sym::Symbol, r::LReplace)
sym == r.pat_sym && return r.val
symbol(lreplace!(string(sym), r))
Symbol(lreplace!(string(sym), r))
end

function lreplace!(str::AbstractString, r::LReplace)
Expand Down Expand Up @@ -323,7 +323,7 @@ function lreplace!(ex::Expr, r::LReplace)
if ex.head == :curly && length(ex.args) == 2 && isa(ex.args[1], Symbol) && endswith(string(ex.args[1]), "_")
excurly = Base.Cartesian.exprresolve(lreplace!(ex.args[2], r))
if isa(excurly, Number)
return symbol(ex.args[1],excurly)
return Symbol(ex.args[1],excurly)
else
ex.args[2] = excurly
return ex
Expand Down
4 changes: 2 additions & 2 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ default_color_info = :blue
color_normal = text_colors[:normal]

function repl_color(key, default)
c = symbol(get(ENV, key, ""))
c = Symbol(get(ENV, key, ""))
haskey(text_colors, c) ? c : default
end

Expand Down Expand Up @@ -284,7 +284,7 @@ function load_machine_file(path::AbstractString)
for line in split(readstring(path),'\n'; keep=false)
s = map!(strip, split(line,'*'; keep=false))
if length(s) > 1
cnt = isnumber(s[1]) ? parse(Int,s[1]) : symbol(s[1])
cnt = isnumber(s[1]) ? parse(Int,s[1]) : Symbol(s[1])
push!(machines,(s[2], cnt))
else
push!(machines,line)
Expand Down
2 changes: 1 addition & 1 deletion base/dates/accessors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ end

for parts in (["year", "month"], ["month", "day"], ["year", "month", "day"])
name = join(parts)
func = symbol(name)
func = Symbol(name)
@eval begin
@doc """
$($name)(dt::TimeType) -> ($(join(repeated(Int64, length($parts)), ", ")))
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:end])
@eval begin
# GeneralPeriod, AbstractArray{TimeType}
($op){T<:TimeType}(x::AbstractArray{T}, y::GeneralPeriod) =
Expand Down
6 changes: 3 additions & 3 deletions base/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ for period in (:Year, :Month, :Week, :Day, :Hour, :Minute, :Second, :Millisecond

The $($accessor_str) part of a $($description) as a `$($period_str)`.$($reference)
""" ->
$period(dt::$(symbol(typ_str))) = $period($(symbol(accessor_str))(dt))
$period(dt::$(Symbol(typ_str))) = $period($(Symbol(accessor_str))(dt))

@doc """
$($period_str)(v)
Expand Down Expand Up @@ -87,7 +87,7 @@ for (op,Ty,Tz) in ((:.*,Real,:P),
(:div,:P,Int64), (:div,Integer,:P),
(:mod,:P,Int64), (:mod,Integer,:P))
sop = string(op)
op_ = sop[1] == '.' ? symbol(sop[2:end]) : op
op_ = sop[1] == '.' ? Symbol(sop[2:end]) : op
@eval begin
function ($op){P<:Period}(X::StridedArray{P},y::$Ty)
Z = similar(X, $Tz)
Expand Down Expand Up @@ -229,7 +229,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:end])
Copy link
Member

Choose a reason for hiding this comment

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

Probably clearer to use [2] here rather than [2:end]

@eval begin
function ($op){P<:GeneralPeriod}(X::StridedArray{P},y::GeneralPeriod)
Z = similar(X, CompoundPeriod)
Expand Down
8 changes: 5 additions & 3 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ end
@deprecate_binding MathConst Irrational

macro math_const(sym, val, def)
depwarn("@math_const is deprecated and renamed to @irrational.", symbol("@math_const"))
depwarn("@math_const is deprecated and renamed to @irrational.", Symbol("@math_const"))
:(@irrational $(esc(sym)) $(esc(val)) $(esc(def)))
end
export @math_const
Expand Down Expand Up @@ -692,7 +692,7 @@ include("require.jl")
# require("Foo") --- ambiguous. might be file or package
filename = maybe_require_file(f)
if filename == f
mod = symbol(require_modname(f))
mod = Symbol(require_modname(f))
M = current_module()
if isdefined(M,mod) && isa(eval(M,mod),Module)
return
Expand Down Expand Up @@ -933,7 +933,7 @@ end

#14474
macro boundscheck(yesno,blk)
depwarn("The meaning of `@boundscheck` has changed. It now indicates that the provided code block performs bounds checking, and may be elided when inbounds.", symbol("@boundscheck"))
depwarn("The meaning of `@boundscheck` has changed. It now indicates that the provided code block performs bounds checking, and may be elided when inbounds.", Symbol("@boundscheck"))
if yesno === true
:(@inbounds $(esc(blk)))
end
Expand Down Expand Up @@ -1020,6 +1020,8 @@ function pmap(f, c...; err_retry=nothing, err_stop=nothing, pids=nothing)
return pmap(p, f, c...)
end

#15995
@deprecate symbol Symbol

# During the 0.5 development cycle, do not add any deprecations below this line
# To be deprecated in 0.6
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(string("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(string("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(string("plan_", f))
Copy link
Member

Choose a reason for hiding this comment

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

Note that usages like this should probably be replaced with 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
6 changes: 3 additions & 3 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ const keywords = Dict{Symbol, DocStr}()
isdoc(s::AbstractString) = true

isdoc(x) = isexpr(x, :string) ||
(isexpr(x, :macrocall) && x.args[1] == symbol("@doc_str")) ||
(isexpr(x, :macrocall) && x.args[1] == Symbol("@doc_str")) ||
(isexpr(x, :call) && x.args[1] == Base.Markdown.doc_str)

function unblock(ex)
Expand All @@ -417,7 +417,7 @@ nameof(q::QuoteNode, ismacro) = nameof(q.value, ismacro)
nameof(s::Symbol, ismacro) = ismacro ? macroname(s) : s
nameof(other, ismacro) = other

macroname(s::Symbol) = symbol('@', s)
macroname(s::Symbol) = Symbol('@', s)
macroname(x::Expr) = Expr(x.head, x.args[1], macroname(x.args[end].value))

isfield(x) = isexpr(x, :.) &&
Expand Down Expand Up @@ -538,7 +538,7 @@ function __doc__!(meta, def, define)
# the Base image). We just need to convert each `@__doc__` marker to an `@doc`.
finddoc(def) do each
each.head = :macrocall
each.args = [symbol("@doc"), meta, each.args[end], define]
each.args = [Symbol("@doc"), meta, each.args[end], define]
end
else
# `def` has already been defined during Base image gen so we just need to find and
Expand Down
2 changes: 1 addition & 1 deletion base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module BaseDocs
immutable Keyword
name :: Symbol
end
macro kw_str(text) Keyword(symbol(text)) end
macro kw_str(text) Keyword(Symbol(text)) end

"Hello, Human."
kw"hello", kw"hi"
Expand Down
4 changes: 2 additions & 2 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6793,7 +6793,7 @@ to define a new `writemime` method for `T`, via: `writemime(stream, ::MIME"mime"
where `mime` is a MIME-type string and the function body calls `write` (or similar) to write
that representation of `x` to `stream`. (Note that the `MIME""` notation only supports
literal strings; to construct `MIME` types in a more flexible manner use
`MIME{symbol("")}`.)
`MIME{Symbol("")}`.)

For example, if you define a `MyImage` type and know how to write it to a PNG file, you
could define a function `writemime(stream, ::MIME"image/png", x::MyImage) = ...` to allow
Expand Down Expand Up @@ -9576,7 +9576,7 @@ Create an array of all zeros with the same element type and shape as `A`.
zeros(A)

"""
symbol(x...) -> Symbol
Symbol(x...) -> Symbol

Create a `Symbol` by concatenating the string representations of the arguments together.
"""
Expand Down
6 changes: 3 additions & 3 deletions base/docs/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ end
function helpmode(line::AbstractString)
line = strip(line)
expr =
if haskey(keywords, symbol(line))
if haskey(keywords, Symbol(line))
# Docs for keywords must be treated separately since trying to parse a single
# keyword such as `function` would throw a parse error due to the missing `end`.
symbol(line)
Symbol(line)
else
x = Base.syntax_deprecation_warnings(false) do
parse(line, raise = false)
Expand Down Expand Up @@ -141,7 +141,7 @@ function repl(s::Symbol)
end
end

isregex(x) = isexpr(x, :macrocall, 2) && x.args[1] == symbol("@r_str") && !isempty(x.args[2])
isregex(x) = isexpr(x, :macrocall, 2) && x.args[1] == Symbol("@r_str") && !isempty(x.args[2])

repl(ex::Expr) = isregex(ex) ? :(apropos($ex)) : _repl(ex)

Expand Down
10 changes: 5 additions & 5 deletions base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

## symbols ##

symbol(s::Symbol) = s
symbol(s::ASCIIString) = symbol(s.data)
symbol(s::UTF8String) = symbol(s.data)
symbol(a::Array{UInt8,1}) =
Symbol(s::Symbol) = s
Copy link
Member

Choose a reason for hiding this comment

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

OTOH this constructor is probably useless due to the fallback to convert.

Copy link
Member

Choose a reason for hiding this comment

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

Is this what's causing the method error(s) @tkelman noticed?

...but like I say removing the convert kills the build. :/

Copy link
Member

Choose a reason for hiding this comment

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

As @nalimilan said, the default constructor calls convert, not the other way around, so if you remove something it should be the constructor(s).

Symbol(s::ASCIIString) = Symbol(s.data)
Symbol(s::UTF8String) = Symbol(s.data)
Symbol(a::Array{UInt8,1}) =
ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Int32), a, length(a))
symbol(x...) = symbol(string(x...))
Symbol(x...) = Symbol(string(x...))

gensym() = ccall(:jl_gensym, Ref{Symbol}, ())

Expand Down
6 changes: 3 additions & 3 deletions base/fft/FFTW.jl
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ fftwfloat{T<:Real}(X::AbstractArray{T}) = copy!(Array(Float64, size(X)), X)
fftwfloat{T<:Complex}(X::AbstractArray{T}) = fftwcomplex(X)

for (f,direction) in ((:fft,FORWARD), (:bfft,BACKWARD))
plan_f = symbol("plan_",f)
plan_f! = symbol("plan_",f,"!")
plan_f = Symbol("plan_",f)
plan_f! = Symbol("plan_",f,"!")
idirection = -direction
@eval begin
function $plan_f{T<:fftwComplex,N}(X::StridedArray{T,N}, region;
Expand Down Expand Up @@ -734,7 +734,7 @@ plan_brfft
# FFTW r2r transforms (low-level interface)

for f in (:r2r, :r2r!)
pf = symbol("plan_", f)
pf = Symbol("plan_", f)
@eval begin
$f{T<:fftwNumber}(x::AbstractArray{T}, kinds) = $pf(x, kinds) * x
$f{T<:fftwNumber}(x::AbstractArray{T}, kinds, region) = $pf(x, kinds, 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(string("plan_", f))
Copy link
Member

Choose a reason for hiding this comment

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

no need to call string

@eval begin
$f{T<:fftwNumber}(x::AbstractArray{T}) = $pf(x) * x
$f{T<:fftwNumber}(x::AbstractArray{T}, region) = $pf(x, region) * x
Expand Down
2 changes: 1 addition & 1 deletion base/latex_symbols.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ open(fname) do f
x = map(s -> rstrip(s, [' ','\t','\n']),
split(replace(L, r"[{}\"]+", "\t"), "\t"))
c = Char(parse(Int, x[2], 16))
if (Base.is_id_char(c) || Base.isoperator(symbol(c))) &&
if (Base.is_id_char(c) || Base.isoperator(Symbol(c))) &&
string(c) ∉ latex_strings && !isascii(c)
tabcomname = escape_string(x[3])
if startswith(tabcomname, "\\\\math")
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)
Copy link
Member

Choose a reason for hiding this comment

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

Replace * with ,.

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
2 changes: 1 addition & 1 deletion base/linalg/arnoldi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function _eigs(A, B;

if isa(which,AbstractString)
warn("Use symbols instead of strings for specifying which eigenvalues to compute")
which=symbol(which)
which=Symbol(which)
end
if (which != :LM && which != :SM && which != :LR && which != :SR &&
which != :LI && which != :SI && which != :BE)
Expand Down
10 changes: 5 additions & 5 deletions base/linalg/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ size(C::Union{Cholesky, CholeskyPivoted}) = size(C.factors)
size(C::Union{Cholesky, CholeskyPivoted}, d::Integer) = size(C.factors, d)

function getindex{T,S}(C::Cholesky{T,S}, d::Symbol)
d == :U && return UpperTriangular(symbol(C.uplo) == d ? C.factors : C.factors')
d == :L && return LowerTriangular(symbol(C.uplo) == d ? C.factors : C.factors')
d == :UL && return symbol(C.uplo) == :U ? UpperTriangular(C.factors) : LowerTriangular(C.factors)
d == :U && return UpperTriangular(Symbol(C.uplo) == d ? C.factors : C.factors')
d == :L && return LowerTriangular(Symbol(C.uplo) == d ? C.factors : C.factors')
d == :UL && return Symbol(C.uplo) == :U ? UpperTriangular(C.factors) : LowerTriangular(C.factors)
throw(KeyError(d))
end
function getindex{T<:BlasFloat}(C::CholeskyPivoted{T}, d::Symbol)
d == :U && return UpperTriangular(symbol(C.uplo) == d ? C.factors : C.factors')
d == :L && return LowerTriangular(symbol(C.uplo) == d ? C.factors : C.factors')
d == :U && return UpperTriangular(Symbol(C.uplo) == d ? C.factors : C.factors')
d == :L && return LowerTriangular(Symbol(C.uplo) == d ? C.factors : C.factors')
d == :p && return C.piv
if d == :P
n = size(C, 1)
Expand Down
Loading