From 4467508bd47374933fa27b9125ab6c44ed266479 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 7 Feb 2017 12:42:03 -0500 Subject: [PATCH] deprecate `typealias` in favor of `const` assignment or `A{B} = ...` --- NEWS.md | 3 ++ base/REPLCompletions.jl | 2 +- base/abstractarray.jl | 2 +- base/array.jl | 32 +++++++-------- base/atomics.jl | 6 +-- base/bitarray.jl | 4 +- base/boot.jl | 8 ++-- base/broadcast.jl | 2 +- base/c.jl | 22 +++++----- base/checked.jl | 20 ++++----- base/complex.jl | 6 +-- base/ctypes.jl | 28 ++++++------- base/dates/periods.jl | 4 +- base/deprecated.jl | 3 ++ base/dft.jl | 2 +- base/dict.jl | 2 +- base/docs/Docs.jl | 3 +- base/docs/basedocs.jl | 18 -------- base/docs/utils.jl | 2 +- base/essentials.jl | 2 +- base/fft/FFTW.jl | 16 ++++---- base/gmp.jl | 14 +++---- base/grisu/bignums.jl | 4 +- base/inference.jl | 4 +- base/int.jl | 16 ++++---- base/iobuffer.jl | 2 +- base/linalg/conjarray.jl | 4 +- base/linalg/generic.jl | 2 +- base/linalg/linalg.jl | 10 ++--- base/linalg/rowvector.jl | 2 +- base/linalg/symmetric.jl | 4 +- base/locks.jl | 4 +- base/markdown/parse/config.jl | 2 +- base/math.jl | 2 +- base/mmap.jl | 2 +- base/multidimensional.jl | 2 +- base/nullable.jl | 16 ++++---- base/operators.jl | 6 +-- base/ordering.jl | 2 +- base/pkg/query.jl | 2 +- base/pkg/resolve/fieldvalue.jl | 2 +- base/pkg/types.jl | 8 ++-- base/process.jl | 4 +- base/profile.jl | 4 +- base/reduce.jl | 12 +++--- base/reshapedarray.jl | 4 +- base/sharedarray.jl | 4 +- base/show.jl | 8 +--- base/sort.jl | 2 +- base/sparse/abstractsparse.jl | 4 +- base/sparse/cholmod.jl | 2 +- base/sparse/cholmod_h.jl | 8 ++-- base/sparse/sparsevector.jl | 36 ++++++++-------- base/sparse/umfpack.jl | 6 +-- base/stacktraces.jl | 2 +- base/stream.jl | 2 +- base/strings/search.jl | 2 +- base/strings/string.jl | 2 +- base/subarray.jl | 12 +++--- base/sysimg.jl | 10 ++--- base/tuple.jl | 8 ++-- doc/src/manual/calling-c-and-fortran-code.md | 3 +- doc/src/manual/documentation.md | 13 ++---- doc/src/manual/types.md | 43 ++++++++++---------- doc/src/stdlib/simd-types.md | 2 +- src/julia-parser.scm | 8 +++- src/julia-syntax.scm | 38 ++++++++--------- test/TestHelpers.jl | 2 +- test/ccall.jl | 12 +++--- test/core.jl | 30 +++++++------- test/docs.jl | 2 +- test/inference.jl | 2 +- test/parse.jl | 4 +- test/perf/kernel/actor_centrality.jl | 2 +- test/show.jl | 4 +- test/vecelement.jl | 2 +- 76 files changed, 285 insertions(+), 311 deletions(-) diff --git a/NEWS.md b/NEWS.md index b6de3fd36f681..5f0e9d6781dab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 ---------------- diff --git a/base/REPLCompletions.jl b/base/REPLCompletions.jl index 32dceecb5c2ad..971a78a32fa02 100644 --- a/base/REPLCompletions.jl +++ b/base/REPLCompletions.jl @@ -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) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 1a61da847e75f..d69460476bd8c 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -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) diff --git a/base/array.jl b/base/array.jl index 5e7c4bcc8b7c0..795baa4262c69 100644 --- a/base/array.jl +++ b/base/array.jl @@ -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 ## diff --git a/base/atomics.jl b/base/atomics.jl index b43ccd4f71047..743bb0501e3d3 100644 --- a/base/atomics.jl +++ b/base/atomics.jl @@ -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} diff --git a/base/bitarray.jl b/base/bitarray.jl index 4809be5e173d9..230df0b3990b8 100644 --- a/base/bitarray.jl +++ b/base/bitarray.jl @@ -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) diff --git a/base/boot.jl b/base/boot.jl index dbbdb112fcbac..1933e511210c5 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -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 @@ -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 @@ -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 diff --git a/base/broadcast.jl b/base/broadcast.jl index d7a1ba8ae583b..d85194e670cc9 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -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 diff --git a/base/c.jl b/base/c.jl index d3a1b075a28e6..1e9764e1c12aa 100644 --- a/base/c.jl +++ b/base/c.jl @@ -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 @@ -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 """ @@ -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 diff --git a/base/checked.jl b/base/checked.jl index 1500723947d10..37310d0a35e90 100644 --- a/base/checked.jl +++ b/base/checked.jl @@ -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 @@ -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) diff --git a/base/complex.jl b/base/complex.jl index e2156adc257fb..4a1ae9ed210e1 100644 --- a/base/complex.jl +++ b/base/complex.jl @@ -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)) diff --git a/base/ctypes.jl b/base/ctypes.jl index 037cfd74ad638..6dccd586459ca 100644 --- a/base/ctypes.jl +++ b/base/ctypes.jl @@ -8,7 +8,7 @@ Equivalent to the native `unsigned char` c-type (`UInt8`). """ -typealias Cuchar UInt8 +const Cuchar = UInt8 """ @@ -16,7 +16,7 @@ typealias Cuchar UInt8 Equivalent to the native `signed short` c-type (`Int16`). """ -typealias Cshort Int16 +const Cshort = Int16 """ @@ -24,7 +24,7 @@ typealias Cshort Int16 Equivalent to the native `unsigned short` c-type (`UInt16`). """ -typealias Cushort UInt16 +const Cushort = UInt16 """ @@ -32,7 +32,7 @@ typealias Cushort UInt16 Equivalent to the native `signed int` c-type (`Int32`). """ -typealias Cint Int32 +const Cint = Int32 """ @@ -40,7 +40,7 @@ typealias Cint Int32 Equivalent to the native `unsigned int` c-type (`UInt32`). """ -typealias Cuint UInt32 +const Cuint = UInt32 """ @@ -48,7 +48,7 @@ typealias Cuint UInt32 Equivalent to the native `ptrdiff_t` c-type (`Int`). """ -typealias Cptrdiff_t Int +const Cptrdiff_t = Int """ @@ -56,7 +56,7 @@ typealias Cptrdiff_t Int Equivalent to the native `size_t` c-type (`UInt`). """ -typealias Csize_t UInt +const Csize_t = UInt """ @@ -64,7 +64,7 @@ typealias Csize_t UInt Equivalent to the native `ssize_t` c-type. """ -typealias Cssize_t Int +const Cssize_t = Int """ @@ -72,7 +72,7 @@ typealias Cssize_t Int Equivalent to the native `intmax_t` c-type (`Int64`). """ -typealias Cintmax_t Int64 +const Cintmax_t = Int64 """ @@ -80,7 +80,7 @@ typealias Cintmax_t Int64 Equivalent to the native `uintmax_t` c-type (`UInt64`). """ -typealias Cuintmax_t UInt64 +const Cuintmax_t = UInt64 """ @@ -88,7 +88,7 @@ typealias Cuintmax_t UInt64 Equivalent to the native `signed long long` c-type (`Int64`). """ -typealias Clonglong Int64 +const Clonglong = Int64 """ @@ -96,7 +96,7 @@ typealias Clonglong Int64 Equivalent to the native `unsigned long long` c-type (`UInt64`). """ -typealias Culonglong UInt64 +const Culonglong = UInt64 """ @@ -104,7 +104,7 @@ typealias Culonglong UInt64 Equivalent to the native `float` c-type (`Float32`). """ -typealias Cfloat Float32 +const Cfloat = Float32 """ @@ -112,4 +112,4 @@ typealias Cfloat Float32 Equivalent to the native `double` c-type (`Float64`). """ -typealias Cdouble Float64 +const Cdouble = Float64 diff --git a/base/dates/periods.jl b/base/dates/periods.jl index c85fef65f82ea..0779d8446fed6 100644 --- a/base/dates/periods.jl +++ b/base/dates/periods.jl @@ -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) @@ -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()) diff --git a/base/deprecated.jl b/base/deprecated.jl index 4f6671d15a738..eb53183797fca 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -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) diff --git a/base/dft.jl b/base/dft.jl index b5c2955bedb8a..bbef1f433e550 100644 --- a/base/dft.jl +++ b/base/dft.jl @@ -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 diff --git a/base/dict.jl b/base/dict.jl index 2e99fb60dbffb..4fe8ce2d669e3 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -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) diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index f067851664368..5c112ea32f698 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -619,7 +619,7 @@ finddoc(λ, def) = false # Predicates and helpers for `docm` expression selection: const FUNC_HEADS = [:function, :stagedfunction, :macro, :(=)] -const BINDING_HEADS = [:typealias, :const, :global, :(=)] +const BINDING_HEADS = [:typealias, :const, :global, :(=)] # deprecation: remove `typealias` post-0.6 # For the special `:@mac` / `:(Base.@mac)` syntax for documenting a macro after definition. isquotedmacrocall(x) = isexpr(x, :copyast, 1) && @@ -669,7 +669,6 @@ function docm(meta, ex, define = true) # "Bindings". Names that resolve to objects with different names, ie. # - # typealias T S # const T = S # T = S # global T = S diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 002d8846e8091..2e90a0a73161f 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -641,24 +641,6 @@ See the manual for more details, such as how to define constructors. """ kw"struct" -""" -Introduce a new name for an already expressible type. For example, in `base/boot.jl`, -`UInt` is type aliased to either `UInt64` or `UInt32` as appropriate for the size of -pointers on the system: - - if Int === Int64 - typealias UInt UInt64 - else - typealias UInt UInt32 - end - -For parametric types, `typealias` can be convenient for providing names in cases where -some parameter choices are fixed. In `base` for example: - - typealias Vector{T} Array{T,1} -""" -kw"typealias" - """ `mutable struct` is similar to `struct`, but additionally allows the fields of the type to be set after construction. See `struct` and the manual for more information. diff --git a/base/docs/utils.jl b/base/docs/utils.jl index 6962ad16c3442..973c49eb2ee06 100644 --- a/base/docs/utils.jl +++ b/base/docs/utils.jl @@ -353,7 +353,7 @@ const builtins = ["abstract type", "baremodule", "begin", "break", "elseif", "end", "export", "finally", "for", "function", "global", "if", "import", "importall", "let", "local", "macro", "module", "mutable struct", "primitive type", - "quote", "return", "struct", "try", "typealias", "using", "while"] + "quote", "return", "struct", "try", "using", "while"] moduleusings(mod) = ccall(:jl_module_usings, Any, (Any,), mod) diff --git a/base/essentials.jl b/base/essentials.jl index 9c9f0e66e3427..0e288db962484 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -2,7 +2,7 @@ using Core: CodeInfo -typealias Callable Union{Function,Type} +const Callable = Union{Function,Type} const Bottom = Union{} diff --git a/base/fft/FFTW.jl b/base/fft/FFTW.jl index 34b677e43c922..d68e302c98a8e 100644 --- a/base/fft/FFTW.jl +++ b/base/fft/FFTW.jl @@ -61,13 +61,13 @@ end # FFTW floating-point types: -typealias fftwNumber Union{Float64,Float32,Complex128,Complex64} -typealias fftwReal Union{Float64,Float32} -typealias fftwComplex Union{Complex128,Complex64} -typealias fftwDouble Union{Float64,Complex128} -typealias fftwSingle Union{Float32,Complex64} -typealias fftwTypeDouble Union{Type{Float64},Type{Complex128}} -typealias fftwTypeSingle Union{Type{Float32},Type{Complex64}} +const fftwNumber = Union{Float64,Float32,Complex128,Complex64} +const fftwReal = Union{Float64,Float32} +const fftwComplex = Union{Complex128,Complex64} +const fftwDouble = Union{Float64,Complex128} +const fftwSingle = Union{Float32,Complex64} +const fftwTypeDouble = Union{Type{Float64},Type{Complex128}} +const fftwTypeSingle = Union{Type{Float32},Type{Complex64}} # For ESTIMATE plans, FFTW allows one to pass NULL for the array pointer, # since it is not written to. Hence, it is convenient to create an @@ -155,7 +155,7 @@ end # pointer type for fftw_plan (opaque pointer) struct fftw_plan_struct end -typealias PlanPtr Ptr{fftw_plan_struct} +const PlanPtr = Ptr{fftw_plan_struct} # Planner timelimits diff --git a/base/gmp.jl b/base/gmp.jl index bdf011e012192..8c4a14102689e 100644 --- a/base/gmp.jl +++ b/base/gmp.jl @@ -12,13 +12,13 @@ import Base: *, +, -, /, <, <<, >>, >>>, <=, ==, >, >=, ^, (~), (&), (|), xor, iszero if Clong == Int32 - typealias ClongMax Union{Int8, Int16, Int32} - typealias CulongMax Union{UInt8, UInt16, UInt32} + const ClongMax = Union{Int8, Int16, Int32} + const CulongMax = Union{UInt8, UInt16, UInt32} else - typealias ClongMax Union{Int8, Int16, Int32, Int64} - typealias CulongMax Union{UInt8, UInt16, UInt32, UInt64} + const ClongMax = Union{Int8, Int16, Int32, Int64} + const CulongMax = Union{UInt8, UInt16, UInt32, UInt64} end -typealias CdoubleMax Union{Float16, Float32, Float64} +const CdoubleMax = Union{Float16, Float32, Float64} gmp_version() = VersionNumber(unsafe_string(unsafe_load(cglobal((:__gmp_version, :libgmp), Ptr{Cchar})))) gmp_bits_per_limb() = Int(unsafe_load(cglobal((:__gmp_bits_per_limb, :libgmp), Cint))) @@ -30,9 +30,9 @@ const GMP_BITS_PER_LIMB = gmp_bits_per_limb() # `unsigned int` or `unsigned long long int`. The correct unsigned type is here named Limb, and must # be used whenever mp_limb_t is in the signature of ccall'ed GMP functions. if GMP_BITS_PER_LIMB == 32 - typealias Limb UInt32 + const Limb = UInt32 elseif GMP_BITS_PER_LIMB == 64 - typealias Limb UInt64 + const Limb = UInt64 else error("GMP: cannot determine the type mp_limb_t (__gmp_bits_per_limb == $GMP_BITS_PER_LIMB)") end diff --git a/base/grisu/bignums.jl b/base/grisu/bignums.jl index db65740cfd848..fe50bf35a12ef 100644 --- a/base/grisu/bignums.jl +++ b/base/grisu/bignums.jl @@ -36,8 +36,8 @@ export Bignum const kMaxSignificantBits = 3584 -typealias Chunk UInt32 -typealias DoubleChunk UInt64 +const Chunk = UInt32 +const DoubleChunk = UInt64 const kChunkSize = sizeof(Chunk) * 8 const kDoubleChunkSize = sizeof(DoubleChunk) * 8 diff --git a/base/inference.jl b/base/inference.jl index d0983b7f4e71e..6771453b07da2 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -49,8 +49,8 @@ const Slot_UsedUndef = 32 struct NotFound end const NF = NotFound() -typealias LineNum Int -typealias VarTable Array{Any,1} +const LineNum = Int +const VarTable = Array{Any,1} # The type of a variable load is either a value or an UndefVarError mutable struct VarState diff --git a/base/int.jl b/base/int.jl index 6e9fa9a80ee06..d26319a3a94ae 100644 --- a/base/int.jl +++ b/base/int.jl @@ -14,14 +14,14 @@ const BitSigned_types = (BitSigned64_types..., Int128) const BitUnsigned_types = (BitUnsigned64_types..., UInt128) const BitInteger_types = (BitSigned_types..., BitUnsigned_types...) -typealias BitSigned64 Union{BitSigned64_types...} -typealias BitUnsigned64 Union{BitUnsigned64_types...} -typealias BitInteger64 Union{BitInteger64_types...} -typealias BitSigned Union{BitSigned_types...} -typealias BitUnsigned Union{BitUnsigned_types...} -typealias BitInteger Union{BitInteger_types...} -typealias BitSigned64T Union{Type{Int8}, Type{Int16}, Type{Int32}, Type{Int64}} -typealias BitUnsigned64T Union{Type{UInt8}, Type{UInt16}, Type{UInt32}, Type{UInt64}} +const BitSigned64 = Union{BitSigned64_types...} +const BitUnsigned64 = Union{BitUnsigned64_types...} +const BitInteger64 = Union{BitInteger64_types...} +const BitSigned = Union{BitSigned_types...} +const BitUnsigned = Union{BitUnsigned_types...} +const BitInteger = Union{BitInteger_types...} +const BitSigned64T = Union{Type{Int8}, Type{Int16}, Type{Int32}, Type{Int64}} +const BitUnsigned64T = Union{Type{UInt8}, Type{UInt16}, Type{UInt32}, Type{UInt64}} ## integer comparisons ## diff --git a/base/iobuffer.jl b/base/iobuffer.jl index af58ba1a5b1e2..a624d791a2f64 100644 --- a/base/iobuffer.jl +++ b/base/iobuffer.jl @@ -19,7 +19,7 @@ mutable struct AbstractIOBuffer{T<:AbstractVector{UInt8}} <: IO new(data,readable,writable,seekable,append,length(data),maxsize,1,-1) end end -typealias IOBuffer AbstractIOBuffer{Vector{UInt8}} +const IOBuffer = AbstractIOBuffer{Vector{UInt8}} function AbstractIOBuffer(data::T, readable::Bool, writable::Bool, seekable::Bool, append::Bool, maxsize::Int) where T<:AbstractVector{UInt8} diff --git a/base/linalg/conjarray.jl b/base/linalg/conjarray.jl index d836994cfda84..3679d5607c49a 100644 --- a/base/linalg/conjarray.jl +++ b/base/linalg/conjarray.jl @@ -27,10 +27,10 @@ end @inline ConjArray{T,N}(a::AbstractArray{T,N}) = ConjArray{conj_type(T), N, typeof(a)}(a) -typealias ConjVector{T, V <: AbstractVector} ConjArray{T, 1, V} +ConjVector{T, V <: AbstractVector} = ConjArray{T, 1, V} @inline ConjVector{T}(v::AbstractVector{T}) = ConjArray{conj_type(T), 1, typeof(v)}(v) -typealias ConjMatrix{T, M <: AbstractMatrix} ConjArray{T, 2, M} +ConjMatrix{T, M <: AbstractMatrix} = ConjArray{T, 2, M} @inline ConjMatrix{T}(m::AbstractMatrix{T}) = ConjArray{conj_type(T), 2, typeof(m)}(m) # This type can cause the element type to change under conjugation - e.g. an array of complex arrays. diff --git a/base/linalg/generic.jl b/base/linalg/generic.jl index bd07f62a6b3f4..da32703c0e9c6 100644 --- a/base/linalg/generic.jl +++ b/base/linalg/generic.jl @@ -1197,7 +1197,7 @@ function logdet(A::AbstractMatrix) return d + log(s) end -typealias NumberArray{T<:Number} AbstractArray{T} +NumberArray{T<:Number} = AbstractArray{T} """ promote_leaf_eltypes(itr) diff --git a/base/linalg/linalg.jl b/base/linalg/linalg.jl index 65d1afea427bc..51ec2ebb76a8c 100644 --- a/base/linalg/linalg.jl +++ b/base/linalg/linalg.jl @@ -178,14 +178,14 @@ export # Constants I -typealias BlasFloat Union{Float64,Float32,Complex128,Complex64} -typealias BlasReal Union{Float64,Float32} -typealias BlasComplex Union{Complex128,Complex64} +const BlasFloat = Union{Float64,Float32,Complex128,Complex64} +const BlasReal = Union{Float64,Float32} +const BlasComplex = Union{Complex128,Complex64} if USE_BLAS64 - typealias BlasInt Int64 + const BlasInt = Int64 else - typealias BlasInt Int32 + const BlasInt = Int32 end # Check that stride of matrix/vector is 1 diff --git a/base/linalg/rowvector.jl b/base/linalg/rowvector.jl index fa9bfa37ea0ec..9af083d1f038a 100644 --- a/base/linalg/rowvector.jl +++ b/base/linalg/rowvector.jl @@ -23,7 +23,7 @@ end @pure check_types{T1,T2}(::Type{T1},::Type{T2}) = T1 === transpose_type(T2) ? nothing : error("Element type mismatch. Tried to create a `RowVector{$T1}` from an `AbstractVector{$T2}`") -typealias ConjRowVector{T, CV <: ConjVector} RowVector{T, CV} +ConjRowVector{T, CV <: ConjVector} = RowVector{T, CV} # The element type may be transformed as transpose is recursive @inline transpose_type{T}(::Type{T}) = promote_op(transpose, T) diff --git a/base/linalg/symmetric.jl b/base/linalg/symmetric.jl index da6986d1193d8..25cafcd2bb5c3 100644 --- a/base/linalg/symmetric.jl +++ b/base/linalg/symmetric.jl @@ -83,8 +83,8 @@ function Hermitian(A::AbstractMatrix, uplo::Symbol=:U) Hermitian{eltype(A),typeof(A)}(A, char_uplo(uplo)) end -typealias HermOrSym{T,S} Union{Hermitian{T,S}, Symmetric{T,S}} -typealias RealHermSymComplexHerm{T<:Real,S} Union{Hermitian{T,S}, Symmetric{T,S}, Hermitian{Complex{T},S}} +HermOrSym{T,S} = Union{Hermitian{T,S}, Symmetric{T,S}} +RealHermSymComplexHerm{T<:Real,S} = Union{Hermitian{T,S}, Symmetric{T,S}, Hermitian{Complex{T},S}} size(A::HermOrSym, d) = size(A.data, d) size(A::HermOrSym) = size(A.data) diff --git a/base/locks.jl b/base/locks.jl index 7ece049fe989b..c6c8d2b0552d2 100644 --- a/base/locks.jl +++ b/base/locks.jl @@ -47,7 +47,7 @@ See also RecursiveSpinLock for a version that permits recursion. See also Mutex for a more efficient version on one core or if the lock may be held for a considerable length of time. """ -typealias SpinLock TatasLock +const SpinLock = TatasLock function lock(l::TatasLock) while true @@ -103,7 +103,7 @@ See also SpinLock for a slightly faster version. See also Mutex for a more efficient version on one core or if the lock may be held for a considerable length of time. """ -typealias RecursiveSpinLock RecursiveTatasLock +const RecursiveSpinLock = RecursiveTatasLock function lock(l::RecursiveTatasLock) if l.ownertid[] == threadid() diff --git a/base/markdown/parse/config.jl b/base/markdown/parse/config.jl index eba41283e5377..0defc1f1fac08 100644 --- a/base/markdown/parse/config.jl +++ b/base/markdown/parse/config.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license -typealias InnerConfig Dict{Char, Vector{Function}} +const InnerConfig = Dict{Char, Vector{Function}} mutable struct Config breaking::Vector{Function} diff --git a/base/math.jl b/base/math.jl index d4145e34bc813..c056ed85fa8b4 100644 --- a/base/math.jl +++ b/base/math.jl @@ -26,7 +26,7 @@ using Base: sign_mask, exponent_mask, exponent_one, exponent_bias, using Core.Intrinsics: sqrt_llvm, powi_llvm -typealias IEEEFloat Union{Float16,Float32,Float64} +const IEEEFloat = Union{Float16,Float32,Float64} # non-type specific math functions """ diff --git a/base/mmap.jl b/base/mmap.jl index 2588ab17813aa..6ff2707d6e5ce 100644 --- a/base/mmap.jl +++ b/base/mmap.jl @@ -67,7 +67,7 @@ end elseif is_windows() -typealias DWORD Culong +const DWORD = Culong const PAGE_READONLY = DWORD(0x02) const PAGE_READWRITE = DWORD(0x04) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index 128c09bfa4e28..07eb83a273b0e 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -371,7 +371,7 @@ _maybe_linear_logical_index(::LinearFast, A, i) = LogicalIndex{Int}(i) @inline to_indices(A, inds, I::Tuple{Colon, Vararg{Any}}) = (uncolon(inds, I), to_indices(A, _maybetail(inds), tail(I))...) -typealias CI0 Union{CartesianIndex{0}, AbstractArray{CartesianIndex{0}}} +const CI0 = Union{CartesianIndex{0}, AbstractArray{CartesianIndex{0}}} uncolon(inds::Tuple{}, I::Tuple{Colon}) = Slice(OneTo(1)) uncolon(inds::Tuple{}, I::Tuple{Colon, Vararg{Any}}) = Slice(OneTo(1)) uncolon(inds::Tuple{}, I::Tuple{Colon, Vararg{CI0}}) = Slice(OneTo(1)) diff --git a/base/nullable.jl b/base/nullable.jl index 5c67f7e51a0a2..c27804abd895f 100644 --- a/base/nullable.jl +++ b/base/nullable.jl @@ -177,14 +177,14 @@ vectorization. """ null_safe_op(f::Any, ::Type, ::Type...) = false -typealias NullSafeSignedInts Union{Type{Int128}, Type{Int16}, Type{Int32}, - Type{Int64}, Type{Int8}} -typealias NullSafeUnsignedInts Union{Type{Bool}, Type{UInt128}, Type{UInt16}, - Type{UInt32}, Type{UInt64}, Type{UInt8}} -typealias NullSafeInts Union{NullSafeSignedInts, NullSafeUnsignedInts} -typealias NullSafeFloats Union{Type{Float16}, Type{Float32}, Type{Float64}} -typealias NullSafeTypes Union{NullSafeInts, NullSafeFloats} -typealias EqualOrLess Union{typeof(isequal), typeof(isless)} +const NullSafeSignedInts = Union{Type{Int128}, Type{Int16}, Type{Int32}, + Type{Int64}, Type{Int8}} +const NullSafeUnsignedInts = Union{Type{Bool}, Type{UInt128}, Type{UInt16}, + Type{UInt32}, Type{UInt64}, Type{UInt8}} +const NullSafeInts = Union{NullSafeSignedInts, NullSafeUnsignedInts} +const NullSafeFloats = Union{Type{Float16}, Type{Float32}, Type{Float64}} +const NullSafeTypes = Union{NullSafeInts, NullSafeFloats} +const EqualOrLess = Union{typeof(isequal), typeof(isless)} null_safe_op{T}(::typeof(identity), ::Type{T}) = isbits(T) diff --git a/base/operators.jl b/base/operators.jl index 7d541134af226..dcfd608e44703 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -2,9 +2,9 @@ ## types ## -typealias Dims{N} NTuple{N,Int} -typealias DimsInteger{N} NTuple{N,Integer} -typealias Indices{N} NTuple{N,AbstractUnitRange} +Dims{N} = NTuple{N,Int} +DimsInteger{N} = NTuple{N,Integer} +Indices{N} = NTuple{N,AbstractUnitRange} """ <:(T1, T2) diff --git a/base/ordering.jl b/base/ordering.jl index 7bfd85f8facb6..227bc48e8521d 100644 --- a/base/ordering.jl +++ b/base/ordering.jl @@ -21,7 +21,7 @@ end ReverseOrdering(rev::ReverseOrdering) = rev.fwd ReverseOrdering{Fwd}(fwd::Fwd) = ReverseOrdering{Fwd}(fwd) -typealias DirectOrdering Union{ForwardOrdering,ReverseOrdering{ForwardOrdering}} +const DirectOrdering = Union{ForwardOrdering,ReverseOrdering{ForwardOrdering}} const Forward = ForwardOrdering() const Reverse = ReverseOrdering(Forward) diff --git a/base/pkg/query.jl b/base/pkg/query.jl index bcd887a74ab51..60af3e120715f 100644 --- a/base/pkg/query.jl +++ b/base/pkg/query.jl @@ -177,7 +177,7 @@ function check_partial_updates(reqs::Requires, end end -typealias PackageState Union{Void,VersionNumber} +const PackageState = Union{Void,VersionNumber} function diff(have::Dict, want::Dict, avail::Dict, fixed::Dict) change = Array{Tuple{String,Tuple{PackageState,PackageState}}}(0) diff --git a/base/pkg/resolve/fieldvalue.jl b/base/pkg/resolve/fieldvalue.jl index 20a79b44f9591..ca64085644101 100644 --- a/base/pkg/resolve/fieldvalue.jl +++ b/base/pkg/resolve/fieldvalue.jl @@ -34,7 +34,7 @@ FieldValue(l0::Integer, l1::VersionWeight) = FieldValue(l0, l1, zero(VersionWeig FieldValue(l0::Integer) = FieldValue(l0, zero(VersionWeight)) FieldValue() = FieldValue(0) -typealias Field Vector{FieldValue} +const Field = Vector{FieldValue} Base.zero(::Type{FieldValue}) = FieldValue() diff --git a/base/pkg/types.jl b/base/pkg/types.jl index de531341bfa80..4a22f5d528d2e 100644 --- a/base/pkg/types.jl +++ b/base/pkg/types.jl @@ -112,7 +112,7 @@ end hash(s::VersionSet, h::UInt) = hash(s.intervals, h + (0x2fd2ca6efa023f44 % UInt)) deepcopy_internal(vs::VersionSet, ::ObjectIdDict) = copy(vs) -typealias Requires Dict{String,VersionSet} +const Requires = Dict{String,VersionSet} function merge_requires!(A::Requires, B::Requires) for (pkg,vers) in B @@ -155,8 +155,8 @@ show(io::IO, f::Fixed) = isempty(f.requires) ? # required by anything that processes these things. -typealias VersionReq Union{VersionNumber,VersionSet} -typealias WhyReq Tuple{VersionReq,Any} +const VersionReq = Union{VersionNumber,VersionSet} +const WhyReq = Tuple{VersionReq,Any} # This is used to keep track of dependency relations when propagating # requirements, so as to emit useful information in case of unsatisfiable @@ -241,6 +241,6 @@ function _show(io::IO, ritem::ResolveBacktraceItem, indent::String, seen::Set{Re end end -typealias ResolveBacktrace Dict{AbstractString,ResolveBacktraceItem} +const ResolveBacktrace = Dict{AbstractString,ResolveBacktraceItem} end # module diff --git a/base/process.jl b/base/process.jl index 162413d3323e1..cd15390ca42d6 100644 --- a/base/process.jl +++ b/base/process.jl @@ -158,8 +158,8 @@ uvtype(::Ptr) = UV_STREAM uvhandle(x::RawFD) = convert(Ptr{Void}, x.fd % UInt) uvtype(x::RawFD) = UV_RAW_FD -typealias Redirectable Union{IO, FileRedirect, RawFD} -typealias StdIOSet NTuple{3, Union{Redirectable, Ptr{Void}}} # XXX: remove Ptr{Void} once libuv is refactored to use upstream release +const Redirectable = Union{IO, FileRedirect, RawFD} +const StdIOSet = NTuple{3, Union{Redirectable, Ptr{Void}}} # XXX: remove Ptr{Void} once libuv is refactored to use upstream release struct CmdRedirect <: AbstractCmd cmd::AbstractCmd diff --git a/base/profile.jl b/base/profile.jl index 02329bc66f4eb..9d9b1f320d46b 100644 --- a/base/profile.jl +++ b/base/profile.jl @@ -73,8 +73,8 @@ Clear any existing backtraces from the internal buffer. """ clear() = ccall(:jl_profile_clear_data, Void, ()) -typealias LineInfoDict Dict{UInt64, Vector{StackFrame}} -typealias LineInfoFlatDict Dict{UInt64, StackFrame} +const LineInfoDict = Dict{UInt64, Vector{StackFrame}} +const LineInfoFlatDict = Dict{UInt64, StackFrame} struct ProfileFormat maxdepth::Int diff --git a/base/reduce.jl b/base/reduce.jl index d950a5ad25e74..eafd39bb173de 100644 --- a/base/reduce.jl +++ b/base/reduce.jl @@ -5,15 +5,15 @@ ###### Generic (map)reduce functions ###### if Int === Int32 -typealias SmallSigned Union{Int8,Int16} -typealias SmallUnsigned Union{UInt8,UInt16} +const SmallSigned = Union{Int8,Int16} +const SmallUnsigned = Union{UInt8,UInt16} else -typealias SmallSigned Union{Int8,Int16,Int32} -typealias SmallUnsigned Union{UInt8,UInt16,UInt32} +const SmallSigned = Union{Int8,Int16,Int32} +const SmallUnsigned = Union{UInt8,UInt16,UInt32} end -typealias CommonReduceResult Union{UInt64,UInt128,Int64,Int128,Float32,Float64} -typealias WidenReduceResult Union{SmallSigned, SmallUnsigned, Float16} +const CommonReduceResult = Union{UInt64,UInt128,Int64,Int128,Float32,Float64} +const WidenReduceResult = Union{SmallSigned, SmallUnsigned, Float16} # r_promote_type: promote T to the type of reduce(op, ::Array{T}) # (some "extra" methods are required here to avoid ambiguity warnings) diff --git a/base/reshapedarray.jl b/base/reshapedarray.jl index eb35307eda6b1..94e3d3f924613 100644 --- a/base/reshapedarray.jl +++ b/base/reshapedarray.jl @@ -10,7 +10,7 @@ end ReshapedArray{T,N}(parent::AbstractArray{T}, dims::NTuple{N,Int}, mi) = ReshapedArray{T,N,typeof(parent),typeof(mi)}(parent, dims, mi) # LinearFast ReshapedArray -typealias ReshapedArrayLF{T,N,P<:AbstractArray} ReshapedArray{T,N,P,Tuple{}} +ReshapedArrayLF{T,N,P<:AbstractArray} = ReshapedArray{T,N,P,Tuple{}} # Fast iteration on ReshapedArrays: use the parent iterator struct ReshapedArrayIterator{I,M} @@ -227,7 +227,7 @@ end end # helpful error message for a common failure case -typealias ReshapedRange{T,N,A<:Range} ReshapedArray{T,N,A,Tuple{}} +ReshapedRange{T,N,A<:Range} = ReshapedArray{T,N,A,Tuple{}} setindex!(A::ReshapedRange, val, index::Int) = _rs_setindex!_err() setindex!(A::ReshapedRange, val, indexes::Int...) = _rs_setindex!_err() setindex!(A::ReshapedRange, val, index::ReshapedIndex) = _rs_setindex!_err() diff --git a/base/sharedarray.jl b/base/sharedarray.jl index e37b94368fde5..134445c898f41 100644 --- a/base/sharedarray.jl +++ b/base/sharedarray.jl @@ -250,8 +250,8 @@ function finalize_refs{T,N}(S::SharedArray{T,N}) S end -typealias SharedVector{T} SharedArray{T,1} -typealias SharedMatrix{T} SharedArray{T,2} +SharedVector{T} = SharedArray{T,1} +SharedMatrix{T} = SharedArray{T,2} length(S::SharedArray) = prod(S.dims) size(S::SharedArray) = S.dims diff --git a/base/show.jl b/base/show.jl index 9dbc7454c228f..c21ee8d4460a4 100644 --- a/base/show.jl +++ b/base/show.jl @@ -410,8 +410,8 @@ show(io::IO, s::Symbol) = show_unquoted_quote_expr(io, s, 0, 0) # eval(parse("Set{Int64}([2,3,1])”) # ==> An actual set # While this isn’t true of ALL show methods, it is of all ASTs. -typealias ExprNode Union{Expr, QuoteNode, Slot, LineNumberNode, - LabelNode, GotoNode, GlobalRef} +const ExprNode = Union{Expr, QuoteNode, Slot, LineNumberNode, + LabelNode, GotoNode, GlobalRef} # Operators have precedence levels from 1-N, and show_unquoted defaults to a # precedence level of 0 (the fourth argument). The top-level print and show # methods use a precedence of -1 to specially allow space-separated macro syntax @@ -880,10 +880,6 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int) show_list(io, args, ' ', indent) end - elseif head === :typealias && nargs == 2 - print(io, "typealias ") - show_list(io, args, ' ', indent) - elseif head === :line && 1 <= nargs <= 2 show_linenumber(io, args...) diff --git a/base/sort.jl b/base/sort.jl index f42f93f12b9fc..424fd92012a98 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -790,7 +790,7 @@ import Core.Intrinsics: slt_int import ..Sort: sort! import ...Order: lt, DirectOrdering -typealias Floats Union{Float32,Float64} +const Floats = Union{Float32,Float64} struct Left <: Ordering end struct Right <: Ordering end diff --git a/base/sparse/abstractsparse.jl b/base/sparse/abstractsparse.jl index 61444fc5fb71e..9e7281e392f59 100644 --- a/base/sparse/abstractsparse.jl +++ b/base/sparse/abstractsparse.jl @@ -2,8 +2,8 @@ abstract type AbstractSparseArray{Tv,Ti,N} <: AbstractArray{Tv,N} end -typealias AbstractSparseVector{Tv,Ti} AbstractSparseArray{Tv,Ti,1} -typealias AbstractSparseMatrix{Tv,Ti} AbstractSparseArray{Tv,Ti,2} +AbstractSparseVector{Tv,Ti} = AbstractSparseArray{Tv,Ti,1} +AbstractSparseMatrix{Tv,Ti} = AbstractSparseArray{Tv,Ti,2} """ issparse(S) diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl index 3a9e2b6fbc86d..b4a4b85f2cc01 100644 --- a/base/sparse/cholmod.jl +++ b/base/sparse/cholmod.jl @@ -1560,7 +1560,7 @@ for (T, f) in ((:Dense, :solve), (:Sparse, :spsolve)) end end -typealias SparseVecOrMat{Tv,Ti} Union{SparseVector{Tv,Ti}, SparseMatrixCSC{Tv,Ti}} +SparseVecOrMat{Tv,Ti} = Union{SparseVector{Tv,Ti}, SparseMatrixCSC{Tv,Ti}} function (\)(L::FactorComponent, b::Vector) reshape(convert(Matrix, L\Dense(b)), length(b)) diff --git a/base/sparse/cholmod_h.jl b/base/sparse/cholmod_h.jl index 7be23f78e4074..f0e7a4d44ae2c 100644 --- a/base/sparse/cholmod_h.jl +++ b/base/sparse/cholmod_h.jl @@ -60,15 +60,15 @@ const MM_HERMITIAN_POSDIAG = 7 if Int(ccall((:jl_cholmod_sizeof_long, :libsuitesparse_wrapper),Csize_t,())) == 4 const SuiteSparse_long = Int32 const IndexTypes = (:Int32, ) - typealias ITypes Union{Int32} + const ITypes = Union{Int32} else const SuiteSparse_long = Int64 const IndexTypes = (:Int32, :Int64) - typealias ITypes Union{Int32, Int64} + const ITypes = Union{Int32, Int64} end -typealias VTypes Union{Complex128, Float64} -typealias VRealTypes Union{Float64} +const VTypes = Union{Complex128, Float64} +const VRealTypes = Union{Float64} mutable struct CHOLMODException <: Exception msg::AbstractString diff --git a/base/sparse/sparsevector.jl b/base/sparse/sparsevector.jl index 25d9183954be2..4be38e220828b 100644 --- a/base/sparse/sparsevector.jl +++ b/base/sparse/sparsevector.jl @@ -853,24 +853,24 @@ vcat(Xin::Union{Vector, AbstractSparseVector}...) = vcat(map(sparse, Xin)...) # TODO: A definition similar to the third exists in base/linalg/bidiag.jl. These definitions # should be consolidated in a more appropriate location, e.g. base/linalg/special.jl. -typealias _SparseArrays Union{SparseVector, SparseMatrixCSC} -typealias _SpecialArrays Union{Diagonal, Bidiagonal, Tridiagonal, SymTridiagonal} -typealias _SparseConcatArrays Union{_SpecialArrays, _SparseArrays} - -typealias _Symmetric_SparseConcatArrays{T,A<:_SparseConcatArrays} Symmetric{T,A} -typealias _Hermitian_SparseConcatArrays{T,A<:_SparseConcatArrays} Hermitian{T,A} -typealias _Triangular_SparseConcatArrays{T,A<:_SparseConcatArrays} Base.LinAlg.AbstractTriangular{T,A} -typealias _Annotated_SparseConcatArrays Union{_Triangular_SparseConcatArrays, _Symmetric_SparseConcatArrays, _Hermitian_SparseConcatArrays} - -typealias _Symmetric_DenseArrays{T,A<:Matrix} Symmetric{T,A} -typealias _Hermitian_DenseArrays{T,A<:Matrix} Hermitian{T,A} -typealias _Triangular_DenseArrays{T,A<:Matrix} Base.LinAlg.AbstractTriangular{T,A} -typealias _Annotated_DenseArrays Union{_Triangular_DenseArrays, _Symmetric_DenseArrays, _Hermitian_DenseArrays} -typealias _Annotated_Typed_DenseArrays{T} Union{_Triangular_DenseArrays{T}, _Symmetric_DenseArrays{T}, _Hermitian_DenseArrays{T}} - -typealias _SparseConcatGroup Union{Vector, Matrix, _SparseConcatArrays, _Annotated_SparseConcatArrays, _Annotated_DenseArrays} -typealias _DenseConcatGroup Union{Vector, Matrix, _Annotated_DenseArrays} -typealias _TypedDenseConcatGroup{T} Union{Vector{T}, Matrix{T}, _Annotated_Typed_DenseArrays{T}} +const _SparseArrays = Union{SparseVector, SparseMatrixCSC} +const _SpecialArrays = Union{Diagonal, Bidiagonal, Tridiagonal, SymTridiagonal} +const _SparseConcatArrays = Union{_SpecialArrays, _SparseArrays} + +const _Symmetric_SparseConcatArrays{T,A<:_SparseConcatArrays} = Symmetric{T,A} +const _Hermitian_SparseConcatArrays{T,A<:_SparseConcatArrays} = Hermitian{T,A} +const _Triangular_SparseConcatArrays{T,A<:_SparseConcatArrays} = Base.LinAlg.AbstractTriangular{T,A} +const _Annotated_SparseConcatArrays = Union{_Triangular_SparseConcatArrays, _Symmetric_SparseConcatArrays, _Hermitian_SparseConcatArrays} + +const _Symmetric_DenseArrays{T,A<:Matrix} = Symmetric{T,A} +const _Hermitian_DenseArrays{T,A<:Matrix} = Hermitian{T,A} +const _Triangular_DenseArrays{T,A<:Matrix} = Base.LinAlg.AbstractTriangular{T,A} +const _Annotated_DenseArrays = Union{_Triangular_DenseArrays, _Symmetric_DenseArrays, _Hermitian_DenseArrays} +const _Annotated_Typed_DenseArrays{T} = Union{_Triangular_DenseArrays{T}, _Symmetric_DenseArrays{T}, _Hermitian_DenseArrays{T}} + +const _SparseConcatGroup = Union{Vector, Matrix, _SparseConcatArrays, _Annotated_SparseConcatArrays, _Annotated_DenseArrays} +const _DenseConcatGroup = Union{Vector, Matrix, _Annotated_DenseArrays} +const _TypedDenseConcatGroup{T} = Union{Vector{T}, Matrix{T}, _Annotated_Typed_DenseArrays{T}} # Concatenations involving un/annotated sparse/special matrices/vectors should yield sparse arrays function cat(catdims, Xin::_SparseConcatGroup...) diff --git a/base/sparse/umfpack.jl b/base/sparse/umfpack.jl index 970a1b3d43325..76c738d0abd5b 100644 --- a/base/sparse/umfpack.jl +++ b/base/sparse/umfpack.jl @@ -60,13 +60,13 @@ end # check the size of SuiteSparse_long if Int(ccall((:jl_cholmod_sizeof_long,:libsuitesparse_wrapper),Csize_t,())) == 4 const UmfpackIndexTypes = (:Int32,) - typealias UMFITypes Int32 + const UMFITypes = Int32 else const UmfpackIndexTypes = (:Int32, :Int64) - typealias UMFITypes Union{Int32, Int64} + const UMFITypes = Union{Int32, Int64} end -typealias UMFVTypes Union{Float64,Complex128} +const UMFVTypes = Union{Float64,Complex128} ## UMFPACK diff --git a/base/stacktraces.jl b/base/stacktraces.jl index 8dc816096008d..a7d9af7037999 100644 --- a/base/stacktraces.jl +++ b/base/stacktraces.jl @@ -67,7 +67,7 @@ StackFrame(func, file, line) = StackFrame(func, file, line, Nullable{Core.Method An alias for `Vector{StackFrame}` provided for convenience; returned by calls to `stacktrace` and `catch_stacktrace`. """ -typealias StackTrace Vector{StackFrame} +const StackTrace = Vector{StackFrame} const empty_sym = Symbol("") const UNKNOWN = StackFrame(empty_sym, empty_sym, -1, Nullable{Core.MethodInstance}(), true, false, 0) # === lookup(C_NULL) diff --git a/base/stream.jl b/base/stream.jl index 04b05d6bf5e63..50526cd94d16a 100644 --- a/base/stream.jl +++ b/base/stream.jl @@ -143,7 +143,7 @@ mutable struct PipeServer <: LibuvServer end end -typealias LibuvPipe Union{PipeEndpoint, PipeServer} +const LibuvPipe = Union{PipeEndpoint, PipeServer} function PipeServer() p = PipeServer(Libc.malloc(_sizeof_uv_named_pipe), StatusUninit) diff --git a/base/strings/search.jl b/base/strings/search.jl index bcbda46be5f33..16ee1019eadc1 100644 --- a/base/strings/search.jl +++ b/base/strings/search.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license -typealias Chars Union{Char,Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} +const Chars = Union{Char,Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} """ search(string::AbstractString, chars::Chars, [start::Integer]) diff --git a/base/strings/string.jl b/base/strings/string.jl index 1cc67be1c2d6b..e7bad62e86613 100644 --- a/base/strings/string.jl +++ b/base/strings/string.jl @@ -1,6 +1,6 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license -typealias ByteArray Union{Vector{UInt8},Vector{Int8}} +const ByteArray = Union{Vector{UInt8},Vector{Int8}} ## constructors and conversions ## diff --git a/base/subarray.jl b/base/subarray.jl index 07cd4f0c595f5..ba083b330b521 100644 --- a/base/subarray.jl +++ b/base/subarray.jl @@ -1,8 +1,8 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license abstract type AbstractCartesianIndex{N} end # This is a hacky forward declaration for CartesianIndex -typealias ViewIndex Union{Real, AbstractArray} -typealias ScalarIndex Real +const ViewIndex = Union{Real, AbstractArray} +const ScalarIndex = Real # L is true if the view itself supports fast linear indexing struct SubArray{T,N,P,I,L} <: AbstractArray{T,N} @@ -146,7 +146,7 @@ end # * Parent index is Colon -> just use the sub-index as provided # * Parent index is scalar -> that dimension was dropped, so skip the sub-index and use the index as is -typealias AbstractZeroDimArray{T} AbstractArray{T, 0} +AbstractZeroDimArray{T} = AbstractArray{T, 0} reindex(V, ::Tuple{}, ::Tuple{}) = () @@ -178,7 +178,7 @@ reindex(V, idxs::Tuple{AbstractMatrix, Vararg{Any}}, subidxs::Tuple{Any, Any, Va end # In general, we simply re-index the parent indices by the provided ones -typealias SlowSubArray{T,N,P,I} SubArray{T,N,P,I,false} +SlowSubArray{T,N,P,I} = SubArray{T,N,P,I,false} function getindex{T,N}(V::SlowSubArray{T,N}, I::Vararg{Int,N}) @_inline_meta @boundscheck checkbounds(V, I...) @@ -186,7 +186,7 @@ function getindex{T,N}(V::SlowSubArray{T,N}, I::Vararg{Int,N}) r end -typealias FastSubArray{T,N,P,I} SubArray{T,N,P,I,true} +FastSubArray{T,N,P,I} = SubArray{T,N,P,I,true} function getindex(V::FastSubArray, i::Int) @_inline_meta @boundscheck checkbounds(V, i) @@ -194,7 +194,7 @@ function getindex(V::FastSubArray, i::Int) r end # We can avoid a multiplication if the first parent index is a Colon or UnitRange -typealias FastContiguousSubArray{T,N,P,I<:Tuple{Union{Slice, UnitRange}, Vararg{Any}}} SubArray{T,N,P,I,true} +FastContiguousSubArray{T,N,P,I<:Tuple{Union{Slice, UnitRange}, Vararg{Any}}} = SubArray{T,N,P,I,true} function getindex(V::FastContiguousSubArray, i::Int) @_inline_meta @boundscheck checkbounds(V, i) diff --git a/base/sysimg.jl b/base/sysimg.jl index bddd182a77f34..ee0ff87f88638 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -139,11 +139,11 @@ using .Iterators: zip, enumerate using .Iterators: Flatten, product # for generators # Definition of StridedArray -typealias StridedReshapedArray{T,N,A<:DenseArray} ReshapedArray{T,N,A} -typealias StridedArray{T,N,A<:Union{DenseArray,StridedReshapedArray},I<:Tuple{Vararg{Union{RangeIndex, AbstractCartesianIndex}}}} Union{DenseArray{T,N}, SubArray{T,N,A,I}, StridedReshapedArray{T,N}} -typealias StridedVector{T,A<:Union{DenseArray,StridedReshapedArray},I<:Tuple{Vararg{Union{RangeIndex, AbstractCartesianIndex}}}} Union{DenseArray{T,1}, SubArray{T,1,A,I}, StridedReshapedArray{T,1}} -typealias StridedMatrix{T,A<:Union{DenseArray,StridedReshapedArray},I<:Tuple{Vararg{Union{RangeIndex, AbstractCartesianIndex}}}} Union{DenseArray{T,2}, SubArray{T,2,A,I}, StridedReshapedArray{T,2}} -typealias StridedVecOrMat{T} Union{StridedVector{T}, StridedMatrix{T}} +StridedReshapedArray{T,N,A<:DenseArray} = ReshapedArray{T,N,A} +StridedArray{T,N,A<:Union{DenseArray,StridedReshapedArray},I<:Tuple{Vararg{Union{RangeIndex, AbstractCartesianIndex}}}} = Union{DenseArray{T,N}, SubArray{T,N,A,I}, StridedReshapedArray{T,N}} +StridedVector{T,A<:Union{DenseArray,StridedReshapedArray},I<:Tuple{Vararg{Union{RangeIndex, AbstractCartesianIndex}}}} = Union{DenseArray{T,1}, SubArray{T,1,A,I}, StridedReshapedArray{T,1}} +StridedMatrix{T,A<:Union{DenseArray,StridedReshapedArray},I<:Tuple{Vararg{Union{RangeIndex, AbstractCartesianIndex}}}} = Union{DenseArray{T,2}, SubArray{T,2,A,I}, StridedReshapedArray{T,2}} +StridedVecOrMat{T} = Union{StridedVector{T}, StridedMatrix{T}} # For OS specific stuff include(string((length(Core.ARGS)>=2 ? Core.ARGS[2] : ""), "build_h.jl")) # include($BUILDROOT/base/build_h.jl) diff --git a/base/tuple.jl b/base/tuple.jl index 2524606556e85..6b12ae49ce914 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -126,10 +126,10 @@ map(f, t::Tuple{Any, Any}) = (f(t[1]), f(t[2])) map(f, t::Tuple{Any, Any, Any}) = (f(t[1]), f(t[2]), f(t[3])) map(f, t::Tuple) = (@_inline_meta; (f(t[1]), map(f,tail(t))...)) # stop inlining after some number of arguments to avoid code blowup -typealias Any16{N} Tuple{Any,Any,Any,Any,Any,Any,Any,Any, - Any,Any,Any,Any,Any,Any,Any,Any,Vararg{Any,N}} -typealias All16{T,N} Tuple{T,T,T,T,T,T,T,T, - T,T,T,T,T,T,T,T,Vararg{T,N}} +Any16{N} = Tuple{Any,Any,Any,Any,Any,Any,Any,Any, + Any,Any,Any,Any,Any,Any,Any,Any,Vararg{Any,N}} +All16{T,N} = Tuple{T,T,T,T,T,T,T,T, + T,T,T,T,T,T,T,T,Vararg{T,N}} function map(f, t::Any16) n = length(t) A = Array{Any}(n) diff --git a/doc/src/manual/calling-c-and-fortran-code.md b/doc/src/manual/calling-c-and-fortran-code.md index bae4528bd693a..1ce2f564c0972 100644 --- a/doc/src/manual/calling-c-and-fortran-code.md +++ b/doc/src/manual/calling-c-and-fortran-code.md @@ -273,7 +273,6 @@ First, a review of some relevant Julia type terminology: | | `Complex128` (`isbits`) | "Is-Bits" :: A `primitive type`, or a `struct` type where all fields are other `isbits` types. It is defined by-value, and is stored without a type-tag. | | `struct ...; end` | `nothing` | "Singleton" :: a Leaf Type or Struct with no fields. | | `(...)` or `tuple(...)` | `(1, 2, 3)` | "Tuple" :: an immutable data-structure similar to an anonymous struct type, or a constant array. Represented as either an array or a struct. | -| `typealias` | Not applicable here | Type aliases, and other similar mechanisms of doing type indirection, are resolved to their base type (this includes assigning a type to another name, or getting the type out of a function call). | ### Bits Types: @@ -521,7 +520,7 @@ __m256 dist( __m256 a, __m256 b ) { The following Julia code calls `dist` using `ccall`: ```julia -typealias m256 NTuple{8, VecElement{Float32}} +const m256 = NTuple{8, VecElement{Float32}} a = m256(ntuple(i -> VecElement(sin(Float32(i))), 8)) b = m256(ntuple(i -> VecElement(cos(Float32(i))), 8)) diff --git a/doc/src/manual/documentation.md b/doc/src/manual/documentation.md index bbf8adc2fcc78..754bca4ca9699 100644 --- a/doc/src/manual/documentation.md +++ b/doc/src/manual/documentation.md @@ -387,16 +387,6 @@ end Adds docstring `"..."` to type `T`, `"x"` to field `T.x` and `"y"` to field `T.y`. Also applicable to `mutable struct` types. -```julia -"..." -typealias A T -``` - -Adds docstring `"..."` to the `Binding``A`. - -`Binding`s are used to store a reference to a particular `Symbol` in a `Module` without storing -the referenced value itself. - ### Modules ```julia @@ -449,6 +439,9 @@ global c = 3 Adds docstring `"..."` to the `Binding`s `a`, `b`, and `c`. +`Binding`s are used to store a reference to a particular `Symbol` in a `Module` without storing +the referenced value itself. + !!! note When a `const` definition is only used to define an alias of another definition, such as is the case with the function `div` and its alias `÷` in `Base`, do not document the alias and instead diff --git a/doc/src/manual/types.md b/doc/src/manual/types.md index 8cef435181167..cc02fb839b529 100644 --- a/doc/src/manual/types.md +++ b/doc/src/manual/types.md @@ -1038,11 +1038,27 @@ of the inner arrays consists of objects of the same type, but this type may vary On the other hand, type `T2` defines a 1-dimensional array of 1-dimensional arrays all of whose inner arrays must have the same type. Note that `T2` is an abstract type, e.g., `Array{Array{Int,1},1} <: T2`, whereas `T1` is a concrete type. As a consequence, `T1` can be constructed with a zero-argument constructor `a=T1()` but `T2` cannot. +There is a convenient syntax for naming such types, similar to the short form of function +definition syntax: + +```julia +Vector{T} = Array{T,1} +``` + +This is equivalent to `const Vector = Array{T,1} where T`. +Writing `Vector{Float64}` is equivalent to writing `Array{Float64,1}`, and the umbrella type +`Vector` has as instances all `Array` objects where the second parameter -- the number of array +dimensions -- is 1, regardless of what the element type is. In languages where parametric types +must always be specified in full, this is not especially helpful, but in Julia, this allows one +to write just `Vector` for the abstract type including all one-dimensional dense arrays of any +element type. + ## Type Aliases -Sometimes it is convenient to introduce a new name for an already expressible type. For such occasions, -Julia provides the `typealias` mechanism. For example, `UInt` is type aliased to either `UInt32` -or `UInt64` as is appropriate for the size of pointers on the system: +Sometimes it is convenient to introduce a new name for an already expressible type. +This can be done with a simple assignment statement. +For example, UInt is aliased to either UInt32 or UInt64 as is appropriate for the size of pointers +on the system: ```julia # 32-bit system: @@ -1058,34 +1074,19 @@ This is accomplished via the following code in `base/boot.jl`: ```julia if Int === Int64 - typealias UInt UInt64 + const UInt = UInt64 else - typealias UInt UInt32 + const UInt = UInt32 end ``` Of course, this depends on what `Int` is aliased to -- but that is predefined to be the correct type -- either `Int32` or `Int64`. -(Note that unlike `Int`, `Float` does not exist as a type-alias for a specific sized `AbstractFloat`. +(Note that unlike `Int`, `Float` does not exist as a type alias for a specific sized `AbstractFloat`. Unlike with integer registers, the floating point register sizes are specified by the IEEE-754 standard. Whereas the size of `Int` reflects the size of a native pointer on that machine.) -For parametric types, `typealias` can be convenient for providing names for cases where some of -the parameter choices are fixed: - -```julia -typealias Vector{T} Array{T,1} -typealias Matrix{T} Array{T,2} -``` - -Writing `Vector{Float64}` is equivalent to writing `Array{Float64,1}`, and the umbrella type -`Vector` has as instances all `Array` objects where the second parameter -- the number of array -dimensions -- is 1, regardless of what the element type is. In languages where parametric types -must always be specified in full, this is not especially helpful, but in Julia, this allows one -to write just `Matrix` for the abstract type including all two-dimensional dense arrays of any -element type. - ## Operations on Types Since types in Julia are themselves objects, ordinary functions can operate on them. Some functions diff --git a/doc/src/stdlib/simd-types.md b/doc/src/stdlib/simd-types.md index 28f7919e010a7..e35c443948707 100644 --- a/doc/src/stdlib/simd-types.md +++ b/doc/src/stdlib/simd-types.md @@ -17,7 +17,7 @@ the following program, when compiled with `julia -O3` generates two SIMD additio (`addps`) on x86 systems: ```julia -typealias m128 NTuple{4,VecElement{Float32}} +const m128 = NTuple{4,VecElement{Float32}} function add(a::m128, b::m128) (VecElement(a[1].value+b[1].value), diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 51bf987c50ea6..e23ec25dc194e 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -1304,8 +1304,12 @@ (string "primitive type " (deparse spec) " " (deparse nb) " end")) (list 'bitstype nb spec))) ((typealias) - (let ((lhs (with-space-sensitive (parse-call s)))) - (list 'typealias lhs (parse-where s)))) + (let ((lhs (with-space-sensitive (parse-call s))) + (rhs (parse-where s))) + (syntax-deprecation s (string "typealias " (deparse lhs) " " (deparse rhs)) + (string (if (symbol? lhs) "const " "") + (deparse lhs) " = " (deparse rhs))) + (list 'typealias lhs rhs))) ((try) (let ((try-block (if (memq (require-token s) '(catch finally)) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index f35ce24f815fb..a85493372fc53 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -1249,27 +1249,19 @@ (scope-block ,catchb))))) (map expand-forms e)))) -(define (expand-typealias e) - (if (and (pair? (cadr e)) - (eq? (car (cadr e)) 'curly)) - (let ((name (cadr (cadr e))) - (params (cddr (cadr e))) - (type-ex (caddr e))) - (receive - (params bounds) (sparam-name-bounds params) - `(block - (const ,name) - (= ,name - (scope-block - (block - ,@(map (lambda (v) `(local ,v)) params) - ,@(map (lambda (l r) (make-assignment l (expand-forms (bounds-to-TypeVar r)))) - params bounds) - ,(foldl (lambda (var type) `(call (core UnionAll) ,var ,type)) - (expand-forms type-ex) - (reverse params)))))))) +(define (expand-typealias name type-ex) + (if (and (pair? name) + (eq? (car name) 'curly)) + (let ((name (cadr name)) + (params (cddr name))) + (if (null? params) + (error (string "empty type parameter list in \"" (deparse `(= (curly ,name) ,type-ex)) "\""))) + `(block + (const ,name) + ,(expand-forms + `(= ,name (where ,type-ex ,@params))))) (expand-forms - `(const (= ,(cadr e) ,(caddr e)))))) + `(const (= ,name ,type-ex))))) ;; take apart e.g. `const a::Int = 0` into `const a; a::Int = 0` (define (expand-const-decl e) @@ -1785,7 +1777,8 @@ 'macro expand-macro-def 'type expand-type-def 'try expand-try - 'typealias expand-typealias + ;; deprecated in 0.6 + 'typealias (lambda (e) (expand-typealias (cadr e) (caddr e))) 'lambda (lambda (e) @@ -1839,6 +1832,9 @@ ;; allow defining functions that use comparison syntax (expand-forms (list* 'function `(call ,(caddr lhs) ,(cadr lhs) ,(cadddr lhs)) (cddr e)))) + ((and (pair? lhs) + (eq? (car lhs) 'curly)) + (expand-typealias (cadr e) (caddr e))) ((assignment? (caddr e)) ;; chain of assignments - convert a=b=c to `b=c; a=c` (let loop ((lhss (list lhs)) diff --git a/test/TestHelpers.jl b/test/TestHelpers.jl index 4afc619c833b5..3b1cd60fe6166 100644 --- a/test/TestHelpers.jl +++ b/test/TestHelpers.jl @@ -58,7 +58,7 @@ struct OffsetArray{T,N,AA<:AbstractArray} <: AbstractArray{T,N} parent::AA offsets::NTuple{N,Int} end -typealias OffsetVector{T,AA<:AbstractArray} OffsetArray{T,1,AA} +OffsetVector{T,AA<:AbstractArray} = OffsetArray{T,1,AA} OffsetArray{T,N}(A::AbstractArray{T,N}, offsets::NTuple{N,Int}) = OffsetArray{T,N,typeof(A)}(A, offsets) OffsetArray{T,N}(A::AbstractArray{T,N}, offsets::Vararg{Int,N}) = OffsetArray(A, offsets) diff --git a/test/ccall.jl b/test/ccall.jl index 661d199e270bc..2e8c067474646 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -894,12 +894,12 @@ end # SIMD Registers -typealias VecReg{N,T} NTuple{N,VecElement{T}} -typealias V2xF32 VecReg{2,Float32} -typealias V4xF32 VecReg{4,Float32} -typealias V2xF64 VecReg{2,Float64} -typealias V2xI32 VecReg{2,Int32} -typealias V4xI32 VecReg{4,Int32} +const VecReg{N,T} = NTuple{N,VecElement{T}} +const V2xF32 = VecReg{2,Float32} +const V4xF32 = VecReg{4,Float32} +const V2xF64 = VecReg{2,Float64} +const V2xI32 = VecReg{2,Int32} +const V4xI32 = VecReg{4,Int32} struct Struct_AA64_1 v1::Int32 diff --git a/test/core.jl b/test/core.jl index ad0548e5cc55f..eb0c646a3b024 100644 --- a/test/core.jl +++ b/test/core.jl @@ -59,7 +59,7 @@ _bound_vararg_specificity_1{T}(::Type{Array{T,1}}, d::Int) = 1 @test _bound_vararg_specificity_1(Array{Int,2}, 1, 1) == 0 # issue #11840 -typealias TT11840{T} Tuple{T,T} +TT11840{T} = Tuple{T,T} f11840(::Type) = "Type" f11840(::DataType) = "DataType" f11840(::UnionAll) = "UnionAll" @@ -569,7 +569,7 @@ let end mutable struct _AA{T}; a::T; end -typealias _AoA{T} _AA{_AA{T}} +_AoA{T} = _AA{_AA{T}} let local g, a g{T}(a::_AA{_AA{T}}) = a @@ -785,7 +785,7 @@ end # issue #814 let local MatOrNot, my_func, M - typealias MatOrNot{T} Union{AbstractMatrix{T}, Vector{Union{}}} + MatOrNot{T} = Union{AbstractMatrix{T}, Vector{Union{}}} my_func{T<:Real}(A::MatOrNot{T}, B::MatOrNot{T}, C::MatOrNot{T}) = 0 M = [ 2. 1. ; 1. 1. ] @test my_func(Union{}[], M, M) == 0 @@ -1102,7 +1102,7 @@ i2619() @test isa(e2619,UndefVarError) && e2619.var === :f # issue #2919 -typealias Foo2919 Int +const Foo2919 = Int mutable struct Baz2919; Foo2919::Foo2919; end @test Baz2919(3).Foo2919 === 3 @@ -1140,8 +1140,8 @@ end @test isa(f3471(Any[1.0,2.0]), Vector{Float64}) # issue #3729 -typealias A3729{B} Vector{Vector{B}} -typealias C3729{D} Vector{Vector{D}} +A3729{B} = Vector{Vector{B}} +C3729{D} = Vector{Vector{D}} @test Vector{Vector{Int}} === A3729{Int} === C3729{Int} # issue #3789 @@ -1204,7 +1204,7 @@ end # issue #4115 #mutable struct Foo4115 #end -#typealias Foo4115s NTuple{3,Union{Foo4115,Type{Foo4115}}} +#const Foo4115s = NTuple{3,Union{Foo4115,Type{Foo4115}}} #baz4115(x::Foo4115s) = x #@test baz4115(convert(Tuple{Type{Foo4115},Type{Foo4115},Foo4115}, # (Foo4115,Foo4115,Foo4115()))) == (Foo4115,Foo4115,Foo4115()) @@ -1843,7 +1843,7 @@ f6980(::Union{Int, Float64}, ::B6980) = true @test f6980(1, B6980()) # issue #7049 -typealias Maybe7049{T} Union{T,Void} +Maybe7049{T} = Union{T,Void} function ttt7049(;init::Maybe7049{Union{AbstractString,Tuple{Int,Char}}} = nothing) string("init=", init) end @@ -1986,7 +1986,7 @@ c99991{T}(::Type{UnitRange{T}},x::Range{T}) = 2 @test c99991(UnitRange{Int}, 1:2) == 2 # issue #17016, method specificity involving vararg tuples -typealias T_17016{N} Tuple{Any,Any,Vararg{Any,N}} +T_17016{N} = Tuple{Any,Any,Vararg{Any,N}} f17016(f, t::T_17016) = 0 f17016(f, t1::Tuple) = 1 @test f17016(0, (1,2,3)) == 0 @@ -2217,7 +2217,7 @@ y8d003 = 777 # issue #9378 abstract type Foo9378{T,S} end struct B9378{T} end -typealias FooB9378{T} Foo9378{T,B9378} +FooB9378{T} = Foo9378{T,B9378} struct CFoo9378 <: FooB9378{Float64} end @test isa(CFoo9378(),FooB9378) @@ -2791,12 +2791,12 @@ gc() @test collect(enumerate((Tuple,3))) == [(1,Tuple), (2,3)] # issue #10978 -typealias TupleType10978{T<:Tuple} Type{T} +TupleType10978{T<:Tuple} = Type{T} f10978(T::TupleType10978) = isa(T, TupleType10978) @test f10978(Tuple{Int}) # issue #10995 -#typealias TupleType{T<:Tuple} Type{T} +#TupleType{T<:Tuple} = Type{T} f10995(::Any) = (while false; end; nothing) f10995(T::TupleType10978) = (while false; end; @assert isa(T, TupleType10978)) g10995(x) = f10995(typeof(x)) @@ -3138,7 +3138,7 @@ end # don't allow non-types in Union @test_throws TypeError Union{1} @test_throws TypeError Union{Int,0} -typealias PossiblyInvalidUnion{T} Union{T,Int} +PossiblyInvalidUnion{T} = Union{T,Int} @test_throws TypeError PossiblyInvalidUnion{1} # issue #12569 @@ -3157,7 +3157,7 @@ cycle_in_solve_tvar_constraints{T}(::Type{T}, x::Val{T}) = 1 # issue #12967 foo12967(x, ::ANY) = 1 -typealias TupleType12967{T<:Tuple} Type{T} +TupleType12967{T<:Tuple} = Type{T} foo12967(x, ::TupleType12967) = 2 @test foo12967(1, Int) == 1 @test foo12967(1, Tuple{}) == 2 @@ -3180,7 +3180,7 @@ struct A11888{T} a::NTuple{16,T} end -typealias B11888{T} A11888{A11888{A11888{T}}} +B11888{T} = A11888{A11888{A11888{T}}} @test sizeof(B11888{B11888{Int64}}) == (1 << 24) * 8 diff --git a/test/docs.jl b/test/docs.jl index 631835ea0689f..21467e68ffae5 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -98,7 +98,7 @@ struct IT end "TA" -typealias TA Union{T, IT} +const TA = Union{T, IT} "@mac()" macro mac() end diff --git a/test/inference.jl b/test/inference.jl index 10095be45fb5d..8b1c707af3147 100644 --- a/test/inference.jl +++ b/test/inference.jl @@ -291,7 +291,7 @@ let g() = Int <: Real ? 1 : "" @test Base.return_types(g, Tuple{}) == [Int] end -typealias NInt{N} Tuple{Vararg{Int, N}} +NInt{N} = Tuple{Vararg{Int, N}} @test Base.eltype(NInt) === Int fNInt(x::NInt) = (x...) gNInt() = fNInt(x) diff --git a/test/parse.jl b/test/parse.jl index 0b2c4731b5c15..fcf27a46e7b6d 100644 --- a/test/parse.jl +++ b/test/parse.jl @@ -857,9 +857,7 @@ end @test method_exists(Mod18756.Type, ()) # issue 18002 -@test parse("typealias a (Int)") == Expr(:typealias, :a, :Int) -@test parse("typealias b (Int,)") == Expr(:typealias, :b, Expr(:tuple, :Int)) -@test parse("typealias Foo{T} Bar{T}") == Expr(:typealias, Expr(:curly, :Foo, :T), Expr(:curly, :Bar, :T)) +@test parse("Foo{T} = Bar{T}") == Expr(:(=), Expr(:curly, :Foo, :T), Expr(:curly, :Bar, :T)) # don't insert push_loc for filename `none` at the top level let ex = expand(parse(""" diff --git a/test/perf/kernel/actor_centrality.jl b/test/perf/kernel/actor_centrality.jl index ae792ed804064..a49f0eb306795 100644 --- a/test/perf/kernel/actor_centrality.jl +++ b/test/perf/kernel/actor_centrality.jl @@ -7,7 +7,7 @@ mutable struct Node Node(name) = new(name, Set{Node}()) end -typealias Graph Dict{String, Node} +const Graph = Dict{String, Node} function get(G::Graph, name) if haskey(G, name) diff --git a/test/show.jl b/test/show.jl index 89309804a6c15..9776ab2da7b50 100644 --- a/test/show.jl +++ b/test/show.jl @@ -564,9 +564,9 @@ let repr = sprint(dump, Int64) @test repr == "Int64 <: Signed\n" end # Make sure a `TypeVar` in a `Union` doesn't break subtype dump. -typealias BreakDump17529{T} Union{T, Void} +BreakDump17529{T} = Union{T, Void} # make sure dependent parameters are represented correctly -typealias VectorVI{I, VI<:AbstractVector{I}} Vector{VI} +VectorVI{I, VI<:AbstractVector{I}} = Vector{VI} let repr = sprint(dump, Any) @test length(repr) > 100000 @test ismatch(r"^Any\n [^ \t\n]", repr) diff --git a/test/vecelement.jl b/test/vecelement.jl index 31de4cb0586e9..6476beade9ad7 100644 --- a/test/vecelement.jl +++ b/test/vecelement.jl @@ -3,7 +3,7 @@ make_value{T<:Integer}(::Type{T}, i::Integer) = 3*i%T make_value{T<:AbstractFloat}(::Type{T},i::Integer) = T(3*i) -typealias Vec{N,T} NTuple{N,Base.VecElement{T}} +Vec{N,T} = NTuple{N,Base.VecElement{T}} # Crash report for #15244 motivated this test. @generated function thrice_iota{N,T}(::Type{Vec{N,T}})