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 typealias in favor of const assignment or A{B} = ... #20500

Merged
merged 1 commit into from
Feb 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ Language changes
* The identifier `_` can be assigned, but accessing its value is deprecated,
allowing this syntax to be used in the future for discarding values ([#9343], [#18251]).

* The `typealias` keyword is deprecated, and should be replaced with
`Vector{T} = Array{T,1}` or a `const` assignment.

Breaking changes
----------------

Expand Down
2 changes: 1 addition & 1 deletion base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function complete_keyword(s::String)
"finally", "for", "function", "global", "if", "import",
"importall", "let", "local", "macro", "module", "mutable struct",
"primitive type", "quote", "return", "struct",
"true", "try", "typealias", "using", "while"]
"true", "try", "using", "while"]
r = searchsorted(sorted_keywords, s)
i = first(r)
n = length(sorted_keywords)
Expand Down
2 changes: 1 addition & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ end

## get (getindex with a default value) ##

typealias RangeVecIntList{A<:AbstractVector{Int}} Union{Tuple{Vararg{Union{Range, AbstractVector{Int}}}}, AbstractVector{UnitRange{Int}}, AbstractVector{Range{Int}}, AbstractVector{A}}
RangeVecIntList{A<:AbstractVector{Int}} = Union{Tuple{Vararg{Union{Range, AbstractVector{Int}}}}, AbstractVector{UnitRange{Int}}, AbstractVector{Range{Int}}, AbstractVector{A}}

get(A::AbstractArray, i::Integer, default) = checkbounds(Bool, A, i) ? A[i] : default
get(A::AbstractArray, I::Tuple{}, default) = similar(A, typeof(default), 0)
Expand Down
32 changes: 16 additions & 16 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

## Type aliases for convenience ##

typealias AbstractVector{T} AbstractArray{T,1}
typealias AbstractMatrix{T} AbstractArray{T,2}
typealias AbstractVecOrMat{T} Union{AbstractVector{T}, AbstractMatrix{T}}
typealias RangeIndex Union{Int, Range{Int}, AbstractUnitRange{Int}}
typealias DimOrInd Union{Integer, AbstractUnitRange}
typealias IntOrInd Union{Int, AbstractUnitRange}
typealias DimsOrInds{N} NTuple{N,DimOrInd}
typealias NeedsShaping Union{Tuple{Integer,Vararg{Integer}}, Tuple{OneTo,Vararg{OneTo}}}

typealias Vector{T} Array{T,1}
typealias Matrix{T} Array{T,2}
typealias VecOrMat{T} Union{Vector{T}, Matrix{T}}

typealias DenseVector{T} DenseArray{T,1}
typealias DenseMatrix{T} DenseArray{T,2}
typealias DenseVecOrMat{T} Union{DenseVector{T}, DenseMatrix{T}}
const AbstractVector{T} = AbstractArray{T,1}
const AbstractMatrix{T} = AbstractArray{T,2}
const AbstractVecOrMat{T} = Union{AbstractVector{T}, AbstractMatrix{T}}
const RangeIndex = Union{Int, Range{Int}, AbstractUnitRange{Int}}
const DimOrInd = Union{Integer, AbstractUnitRange}
const IntOrInd = Union{Int, AbstractUnitRange}
const DimsOrInds{N} = NTuple{N,DimOrInd}
const NeedsShaping = Union{Tuple{Integer,Vararg{Integer}}, Tuple{OneTo,Vararg{OneTo}}}

const Vector{T} = Array{T,1}
const Matrix{T} = Array{T,2}
const VecOrMat{T} = Union{Vector{T}, Matrix{T}}

const DenseVector{T} = DenseArray{T,1}
const DenseMatrix{T} = DenseArray{T,2}
const DenseVecOrMat{T} = Union{DenseVector{T}, DenseMatrix{T}}

## Basic functions ##

Expand Down
6 changes: 3 additions & 3 deletions base/atomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ end
const floattypes = (Float16, Float32, Float64)
# TODO: Support Bool, Ptr
const atomictypes = (inttypes..., floattypes...)
typealias IntTypes Union{inttypes...}
typealias FloatTypes Union{floattypes...}
typealias AtomicTypes Union{atomictypes...}
const IntTypes = Union{inttypes...}
const FloatTypes = Union{floattypes...}
const AtomicTypes = Union{atomictypes...}

"""
Threads.Atomic{T}
Expand Down
4 changes: 2 additions & 2 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ julia> BitArray((3, 1))
BitArray(dims::Integer...) = BitArray(map(Int,dims))
BitArray(dims::NTuple{N,Int}) where {N} = BitArray{N}(dims...)

typealias BitVector BitArray{1}
typealias BitMatrix BitArray{2}
const BitVector = BitArray{1}
const BitMatrix = BitArray{2}

BitVector() = BitArray{1}(0)

Expand Down
8 changes: 4 additions & 4 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export
# constants
nothing, Main

typealias AnyVector Array{Any,1}
const AnyVector = Array{Any,1}

abstract type Number end
abstract type Real <: Number end
Expand Down Expand Up @@ -175,9 +175,9 @@ primitive type Int128 <: Signed 128 end
primitive type UInt128 <: Unsigned 128 end

if Int === Int64
typealias UInt UInt64
const UInt = UInt64
else
typealias UInt UInt32
const UInt = UInt32
end

function Typeof end
Expand Down Expand Up @@ -298,7 +298,7 @@ convert{T}(::Type{T}, x::T) = x
cconvert{T}(::Type{T}, x) = convert(T, x)
unsafe_convert{T}(::Type{T}, x::T) = x

typealias NTuple{N,T} Tuple{Vararg{T,N}}
NTuple{N,T} = Tuple{Vararg{T,N}}


# primitive array constructors
Expand Down
2 changes: 1 addition & 1 deletion base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using Base: linearindices, tail, OneTo, to_shape,
import Base: broadcast, broadcast!
export broadcast_getindex, broadcast_setindex!, dotview, @__dot__

typealias ScalarType Union{Type{Any}, Type{Nullable}}
const ScalarType = Union{Type{Any}, Type{Nullable}}

## Broadcasting utilities ##
# fallbacks for some special cases
Expand Down
22 changes: 11 additions & 11 deletions base/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Core.Intrinsics: cglobal, bitcast
cfunction(f::Function, r, a) = ccall(:jl_function_ptr, Ptr{Void}, (Any, Any, Any), f, r, a)

if ccall(:jl_is_char_signed, Ref{Bool}, ())
typealias Cchar Int8
const Cchar = Int8
else
typealias Cchar UInt8
const Cchar = UInt8
end
"""
Cchar
Expand All @@ -19,13 +19,13 @@ Equivalent to the native `char` c-type.
Cchar

if is_windows()
typealias Clong Int32
typealias Culong UInt32
typealias Cwchar_t UInt16
const Clong = Int32
const Culong = UInt32
const Cwchar_t = UInt16
else
typealias Clong Int
typealias Culong UInt
typealias Cwchar_t Int32
const Clong = Int
const Culong = UInt
const Cwchar_t = Int32
end

"""
Expand All @@ -52,11 +52,11 @@ Cwchar_t
if !is_windows()
const sizeof_mode_t = ccall(:jl_sizeof_mode_t, Cint, ())
if sizeof_mode_t == 2
typealias Cmode_t Int16
const Cmode_t = Int16
elseif sizeof_mode_t == 4
typealias Cmode_t Int32
const Cmode_t = Int32
elseif sizeof_mode_t == 8
typealias Cmode_t Int64
const Cmode_t = Int64
end
end

Expand Down
20 changes: 10 additions & 10 deletions base/checked.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ checked_cld(x::Integer, y::Integer) = checked_cld(promote(x,y)...)
# but no method exists to handle those types
checked_abs{T<:Integer}(x::T) = no_op_err("checked_abs", T)

typealias SignedInt Union{Int8,Int16,Int32,Int64,Int128}
typealias UnsignedInt Union{UInt8,UInt16,UInt32,UInt64,UInt128}
const SignedInt = Union{Int8,Int16,Int32,Int64,Int128}
const UnsignedInt = Union{UInt8,UInt16,UInt32,UInt64,UInt128}

# LLVM has several code generation bugs for checked integer arithmetic (see e.g.
# #4905). We thus distinguish between operations that can be implemented via
Expand Down Expand Up @@ -68,15 +68,15 @@ if llvm_version < 30500
brokenSignedIntMul = Union{brokenSignedIntMul, Int8}
brokenUnsignedIntMul = Union{brokenUnsignedIntMul, UInt8}
end
typealias BrokenSignedInt brokenSignedInt
typealias BrokenUnsignedInt brokenUnsignedInt
typealias BrokenSignedIntMul brokenSignedIntMul
typealias BrokenUnsignedIntMul brokenUnsignedIntMul
const BrokenSignedInt = brokenSignedInt
const BrokenUnsignedInt = brokenUnsignedInt
const BrokenSignedIntMul = brokenSignedIntMul
const BrokenUnsignedIntMul = brokenUnsignedIntMul
# Use these definitions to test the non-LLVM implementations
# typealias BrokenSignedInt SignedInt
# typealias BrokenUnsignedInt UnsignedInt
# typealias BrokenSignedIntMul SignedInt
# typealias BrokenUnsignedIntMul UnsignedInt
# const BrokenSignedInt = SignedInt
# const BrokenUnsignedInt = UnsignedInt
# const BrokenSignedIntMul = SignedInt
# const BrokenUnsignedIntMul = UnsignedInt

"""
Base.checked_neg(x)
Expand Down
6 changes: 3 additions & 3 deletions base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ The imaginary unit.
"""
const im = Complex(false,true)

typealias Complex128 Complex{Float64}
typealias Complex64 Complex{Float32}
typealias Complex32 Complex{Float16}
const Complex128 = Complex{Float64}
const Complex64 = Complex{Float32}
const Complex32 = Complex{Float16}

convert{T<:Real}(::Type{Complex{T}}, x::Real) = Complex{T}(x,0)
convert{T<:Real}(::Type{Complex{T}}, z::Complex) = Complex{T}(real(z),imag(z))
Expand Down
28 changes: 14 additions & 14 deletions base/ctypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,108 +8,108 @@

Equivalent to the native `unsigned char` c-type (`UInt8`).
"""
typealias Cuchar UInt8
const Cuchar = UInt8


"""
Cshort

Equivalent to the native `signed short` c-type (`Int16`).
"""
typealias Cshort Int16
const Cshort = Int16


"""
Cushort

Equivalent to the native `unsigned short` c-type (`UInt16`).
"""
typealias Cushort UInt16
const Cushort = UInt16


"""
Cint

Equivalent to the native `signed int` c-type (`Int32`).
"""
typealias Cint Int32
const Cint = Int32


"""
Cuint

Equivalent to the native `unsigned int` c-type (`UInt32`).
"""
typealias Cuint UInt32
const Cuint = UInt32


"""
Cptrdiff_t

Equivalent to the native `ptrdiff_t` c-type (`Int`).
"""
typealias Cptrdiff_t Int
const Cptrdiff_t = Int


"""
Csize_t

Equivalent to the native `size_t` c-type (`UInt`).
"""
typealias Csize_t UInt
const Csize_t = UInt


"""
Cssize_t

Equivalent to the native `ssize_t` c-type.
"""
typealias Cssize_t Int
const Cssize_t = Int


"""
Cintmax_t

Equivalent to the native `intmax_t` c-type (`Int64`).
"""
typealias Cintmax_t Int64
const Cintmax_t = Int64


"""
Cuintmax_t

Equivalent to the native `uintmax_t` c-type (`UInt64`).
"""
typealias Cuintmax_t UInt64
const Cuintmax_t = UInt64


"""
Clonglong

Equivalent to the native `signed long long` c-type (`Int64`).
"""
typealias Clonglong Int64
const Clonglong = Int64


"""
Culonglong

Equivalent to the native `unsigned long long` c-type (`UInt64`).
"""
typealias Culonglong UInt64
const Culonglong = UInt64


"""
Cfloat

Equivalent to the native `float` c-type (`Float32`).
"""
typealias Cfloat Float32
const Cfloat = Float32


"""
Cdouble

Equivalent to the native `double` c-type (`Float64`).
"""
typealias Cdouble Float64
const Cdouble = Float64
4 changes: 2 additions & 2 deletions base/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ end

# Fixed-value Periods (periods corresponding to a well-defined time interval,
# as opposed to variable calendar intervals like Year).
typealias FixedPeriod Union{Week, Day, Hour, Minute, Second, Millisecond, Microsecond, Nanosecond}
const FixedPeriod = Union{Week, Day, Hour, Minute, Second, Millisecond, Microsecond, Nanosecond}

# like div but throw an error if remainder is nonzero
function divexact(x, y)
Expand Down Expand Up @@ -430,7 +430,7 @@ end
Base.isless{T<:FixedPeriod, S<:FixedPeriod}(x::T, y::S) = isless(promote(x, y)...)

# other periods with fixed conversions but which aren't fixed time periods
typealias OtherPeriod Union{Month, Year}
const OtherPeriod = Union{Month, Year}
let vmax = typemax(Int64) ÷ 12, vmin = typemin(Int64) ÷ 12
@eval function Base.convert(::Type{Month}, x::Year)
$vmin ≤ value(x) ≤ $vmax || throw(InexactError())
Expand Down
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,9 @@ end
end
end

# TODO: remove `:typealias` from BINDING_HEADS in base/docs/Docs.jl
# TODO: remove `'typealias` case in expand-table in julia-syntax.scm

# FloatRange replaced by StepRangeLen

@deprecate FloatRange{T}(start::T, step, len, den) Base.floatrange(T, start, step, len, den)
Expand Down
2 changes: 1 addition & 1 deletion base/dft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export fft, ifft, bfft, fft!, ifft!, bfft!,
plan_fft, plan_ifft, plan_bfft, plan_fft!, plan_ifft!, plan_bfft!,
rfft, irfft, brfft, plan_rfft, plan_irfft, plan_brfft

typealias FFTWFloat Union{Float32,Float64}
const FFTWFloat = Union{Float32,Float64}
fftwfloat(x) = _fftwfloat(float(x))
_fftwfloat{T<:FFTWFloat}(::Type{T}) = T
_fftwfloat(::Type{Float16}) = Float32
Expand Down
2 changes: 1 addition & 1 deletion base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function Dict(kv)
end
end

typealias TP{K,V} Union{Type{Tuple{K,V}},Type{Pair{K,V}}}
TP{K,V} = Union{Type{Tuple{K,V}},Type{Pair{K,V}}}

associative_with_eltype{K,V}(DT_apply, kv, ::TP{K,V}) = DT_apply(K, V)(kv)
associative_with_eltype{K,V}(DT_apply, kv::Generator, ::TP{K,V}) = DT_apply(K, V)(kv)
Expand Down
Loading