Skip to content

Commit

Permalink
some tuple redesign follow-ups
Browse files Browse the repository at this point in the history
- add news item
- remove `, ...` syntax, for now use `Vararg{}` instead
- allow tuples of types in reflection functions
- a couple efficiency tweaks
  • Loading branch information
JeffBezanson committed Apr 17, 2015
1 parent ef06211 commit dccb99c
Show file tree
Hide file tree
Showing 27 changed files with 166 additions and 158 deletions.
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ New language features
Language changes
----------------

* Tuple types are now written as `Tuple{A, B}` instead of as `(A, B)`.
Tuples of bits types are inlined into structs and arrays, like other
immutable types.
`...` now does splatting inside parentheses, instead of constructing a
vararg tuple type. ([#10380])

* Significant improvements to `ccall` and `cfunction`

* As a safer alternative to creating pointers (`Ptr`), the managed reference type
Expand Down Expand Up @@ -1344,6 +1350,7 @@ Too numerous to mention.
[#10328]: https://github.com/JuliaLang/julia/issues/10328
[#10332]: https://github.com/JuliaLang/julia/issues/10332
[#10333]: https://github.com/JuliaLang/julia/issues/10333
[#10380]: https://github.com/JuliaLang/julia/issues/10380
[#10400]: https://github.com/JuliaLang/julia/issues/10400
[#10446]: https://github.com/JuliaLang/julia/issues/10446
[#10458]: https://github.com/JuliaLang/julia/issues/10458
Expand Down
24 changes: 12 additions & 12 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ end

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

typealias RangeVecIntList{A<:AbstractVector{Int}} Union(Tuple{Union(Range, AbstractVector{Int}),...}, AbstractVector{UnitRange{Int}}, AbstractVector{Range{Int}}, AbstractVector{A})
typealias 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) = in_bounds(length(A), i) ? A[i] : default
get(A::AbstractArray, I::Tuple{}, default) = similar(A, typeof(default), 0)
Expand Down Expand Up @@ -727,7 +727,7 @@ function hvcat(nbc::Integer, as...)
hvcat(ntuple(nbr, i->nbc), as...)
end

function hvcat{T}(rows::Tuple{Int,...}, as::AbstractMatrix{T}...)
function hvcat{T}(rows::Tuple{Vararg{Int}}, as::AbstractMatrix{T}...)
nbr = length(rows) # number of block rows

nc = 0
Expand Down Expand Up @@ -770,9 +770,9 @@ function hvcat{T}(rows::Tuple{Int,...}, as::AbstractMatrix{T}...)
out
end

hvcat(rows::Tuple{Int,...}) = []
hvcat(rows::Tuple{Vararg{Int}}) = []

function hvcat{T<:Number}(rows::Tuple{Int,...}, xs::T...)
function hvcat{T<:Number}(rows::Tuple{Vararg{Int}}, xs::T...)
nr = length(rows)
nc = rows[1]

Expand Down Expand Up @@ -805,7 +805,7 @@ function hvcat_fill(a, xs)
a
end

function typed_hvcat(T::Type, rows::Tuple{Int,...}, xs::Number...)
function typed_hvcat(T::Type, rows::Tuple{Vararg{Int}}, xs::Number...)
nr = length(rows)
nc = rows[1]
for i = 2:nr
Expand All @@ -820,13 +820,13 @@ function typed_hvcat(T::Type, rows::Tuple{Int,...}, xs::Number...)
hvcat_fill(Array(T, nr, nc), xs)
end

function hvcat(rows::Tuple{Int,...}, xs::Number...)
function hvcat(rows::Tuple{Vararg{Int}}, xs::Number...)
T = promote_typeof(xs...)
typed_hvcat(T, rows, xs...)
end

# fallback definition of hvcat in terms of hcat and vcat
function hvcat(rows::Tuple{Int,...}, as...)
function hvcat(rows::Tuple{Vararg{Int}}, as...)
nbr = length(rows) # number of block rows
rs = cell(nbr)
a = 1
Expand All @@ -837,7 +837,7 @@ function hvcat(rows::Tuple{Int,...}, as...)
vcat(rs...)
end

function typed_hvcat(T::Type, rows::Tuple{Int,...}, as...)
function typed_hvcat(T::Type, rows::Tuple{Vararg{Int}}, as...)
nbr = length(rows) # number of block rows
rs = cell(nbr)
a = 1
Expand Down Expand Up @@ -1021,7 +1021,7 @@ end
sub2ind{T<:Integer}(dims, I::AbstractVector{T}...) =
[ sub2ind(dims, map(X->X[i], I)...)::Int for i=1:length(I[1]) ]

function ind2sub(dims::Tuple{Integer,Integer,...}, ind::Int)
function ind2sub(dims::Tuple{Integer,Vararg{Integer}}, ind::Int)
ndims = length(dims)
stride = dims[1]
for i=2:ndims-1
Expand All @@ -1038,7 +1038,7 @@ function ind2sub(dims::Tuple{Integer,Integer,...}, ind::Int)
return tuple(ind, sub...)
end

ind2sub(dims::Tuple{Integer,...}, ind::Integer) = ind2sub(dims, Int(ind))
ind2sub(dims::Tuple{Vararg{Integer}}, ind::Integer) = ind2sub(dims, Int(ind))
ind2sub(dims::Tuple{}, ind::Integer) = ind==1 ? () : throw(BoundsError())
ind2sub(dims::Tuple{Integer,}, ind::Int) = (ind,)
ind2sub(dims::Tuple{Integer,Integer}, ind::Int) =
Expand All @@ -1048,7 +1048,7 @@ ind2sub(dims::Tuple{Integer,Integer,Integer}, ind::Int) =
div(rem(ind-1,dims[1]*dims[2]*dims[3]), dims[1]*dims[2])+1)
ind2sub(a::AbstractArray, ind::Integer) = ind2sub(size(a), Int(ind))

function ind2sub{T<:Integer}(dims::Tuple{Integer,Integer,...}, ind::AbstractVector{T})
function ind2sub{T<:Integer}(dims::Tuple{Integer,Vararg{Integer}}, ind::AbstractVector{T})
n = length(dims)
l = length(ind)
t = ntuple(n, x->Array(Int, l))
Expand Down Expand Up @@ -1131,7 +1131,7 @@ end
## iteration utilities ##

# slow, but useful
function cartesianmap(body, t::Tuple{Int,...}, it...)
function cartesianmap(body, t::Tuple{Vararg{Int}}, it...)
idx = length(t)-length(it)
if idx == 1
for i = 1:t[1]
Expand Down
10 changes: 5 additions & 5 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ typealias DenseVector{T} DenseArray{T,1}
typealias DenseMatrix{T} DenseArray{T,2}
typealias DenseVecOrMat{T} Union(DenseVector{T}, DenseMatrix{T})

typealias StridedArray{T,N,A<:DenseArray,I<:Tuple{RangeIndex,...}} Union(DenseArray{T,N}, SubArray{T,N,A,I})
typealias StridedVector{T,A<:DenseArray,I<:Tuple{RangeIndex,...}} Union(DenseArray{T,1}, SubArray{T,1,A,I})
typealias StridedMatrix{T,A<:DenseArray,I<:Tuple{RangeIndex,...}} Union(DenseArray{T,2}, SubArray{T,2,A,I})
typealias StridedArray{T,N,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} Union(DenseArray{T,N}, SubArray{T,N,A,I})
typealias StridedVector{T,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} Union(DenseArray{T,1}, SubArray{T,1,A,I})
typealias StridedMatrix{T,A<:DenseArray,I<:Tuple{Vararg{RangeIndex}}} Union(DenseArray{T,2}, SubArray{T,2,A,I})
typealias StridedVecOrMat{T} Union(StridedVector{T}, StridedMatrix{T})

call{T}(::Type{Vector{T}}, m::Integer) = Array{T}(m)
Expand Down Expand Up @@ -215,7 +215,7 @@ fill(v, dims::Dims) = fill!(Array(typeof(v), dims), v)
fill(v, dims::Integer...) = fill!(Array(typeof(v), dims...), v)

cell(dims::Integer...) = Array(Any, dims...)
cell(dims::Tuple{Integer,...}) = Array(Any, convert(Tuple{Int,...}, dims))
cell(dims::Tuple{Vararg{Integer}}) = Array(Any, convert(Tuple{Vararg{Int}}, dims))

for (fname, felt) in ((:zeros,:zero), (:ones,:one))
@eval begin
Expand Down Expand Up @@ -1286,7 +1286,7 @@ function indcopy(sz::Dims, I::Vector)
dst, src
end

function indcopy(sz::Dims, I::Tuple{RangeIndex,...})
function indcopy(sz::Dims, I::Tuple{Vararg{RangeIndex}})
n = length(I)
s = sz[n]
for i = n+1:length(sz)
Expand Down
8 changes: 4 additions & 4 deletions base/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ convert{T}(::Type{T}, x::T) = x

convert(::Type{Tuple{}}, ::Tuple{}) = ()
convert(::Type{Tuple}, x::Tuple) = x
convert{T}(::Type{Tuple{T,...}}, x::Tuple) = cnvt_all(T, x...)
convert{T}(::Type{Tuple{Vararg{T}}}, x::Tuple) = cnvt_all(T, x...)
cnvt_all(T) = ()
cnvt_all(T, x, rest...) = tuple(convert(T,x), cnvt_all(T, rest...)...)

Expand All @@ -61,7 +61,7 @@ end
argtail(x, rest...) = rest
tail(x::Tuple) = argtail(x...)

convert{T<:Tuple{Any,Any,...}}(::Type{T}, x::Tuple{Any, Any, ...}) =
convert{T<:Tuple{Any,Vararg{Any}}}(::Type{T}, x::Tuple{Any, Vararg{Any}}) =
tuple(convert(tuple_type_head(T),x[1]), convert(tuple_type_tail(T), tail(x))...)

oftype(x,c) = convert(typeof(x),c)
Expand Down Expand Up @@ -264,7 +264,7 @@ end

call{T,N}(::Type{Array{T}}, d::NTuple{N,Int}) =
ccall(:jl_new_array, Array{T,N}, (Any,Any), Array{T,N}, d)
call{T}(::Type{Array{T}}, d::Integer...) = Array{T}(convert(Tuple{Int,...}, d))
call{T}(::Type{Array{T}}, d::Integer...) = Array{T}(convert(Tuple{Vararg{Int}}, d))

call{T}(::Type{Array{T}}, m::Integer) =
ccall(:jl_alloc_array_1d, Array{T,1}, (Any,Int), Array{T,1}, m)
Expand All @@ -275,7 +275,7 @@ call{T}(::Type{Array{T}}, m::Integer, n::Integer, o::Integer) =

# TODO: possibly turn these into deprecations
Array{T,N}(::Type{T}, d::NTuple{N,Int}) = Array{T}(d)
Array{T}(::Type{T}, d::Integer...) = Array{T}(convert(Tuple{Int,...}, d))
Array{T}(::Type{T}, d::Integer...) = Array{T}(convert(Tuple{Vararg{Int}}, d))
Array{T}(::Type{T}, m::Integer) = Array{T}(m)
Array{T}(::Type{T}, m::Integer,n::Integer) = Array{T}(m,n)
Array{T}(::Type{T}, m::Integer,n::Integer,o::Integer) = Array{T}(m,n,o)
Expand Down
4 changes: 2 additions & 2 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,7 @@ function cat(catdim::Integer, X::Union(BitArray, Integer)...)
end
end
# just integers and no BitArrays -> general case
has_bitarray || return invoke(cat, Tuple{Integer, Any, ...}, catdim, X...)
has_bitarray || return invoke(cat, Tuple{Integer, Vararg{Any}}, catdim, X...)
dimsX = map((a->isa(a,BitArray) ? size(a) : (1,)), X)
ndimsX = map((a->isa(a,BitArray) ? ndims(a) : 1), X)
d_max = maximum(ndimsX)
Expand Down Expand Up @@ -1842,7 +1842,7 @@ function cat(catdim::Integer, X::Union(BitArray, Integer)...)
end

ndimsC = max(catdim, d_max)
dimsC = ntuple(ndimsC, compute_dims)::Tuple{Int,...}
dimsC = ntuple(ndimsC, compute_dims)::Tuple{Vararg{Int}}
typeC = promote_type(map(x->isa(x,BitArray) ? eltype(x) : typeof(x), X)...)
if !has_integer || typeC == Bool
C = BitArray(dimsC)
Expand Down
6 changes: 3 additions & 3 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ end
@deprecate median!(v::AbstractVector; checknan::Bool=true) median!(v)

@deprecate Dict{K,V}(ks::AbstractArray{K}, vs::AbstractArray{V}) Dict{K,V}(zip(ks, vs))
@deprecate Dict{K,V}(ks::Tuple{K,...}, vs::Tuple{V,...}) Dict{K,V}(zip(ks, vs))
@deprecate Dict{K}(ks::Tuple{K,...}, vs::Tuple) Dict{K,Any}(zip(ks, vs))
@deprecate Dict{V}(ks::Tuple, vs::Tuple{V,...}) Dict{Any,V}(zip(ks, vs))
@deprecate Dict{K,V}(ks::Tuple{Vararg{K}}, vs::Tuple{Vararg{V}}) Dict{K,V}(zip(ks, vs))
@deprecate Dict{K}(ks::Tuple{Vararg{K}}, vs::Tuple) Dict{K,Any}(zip(ks, vs))
@deprecate Dict{V}(ks::Tuple, vs::Tuple{Vararg{V}}) Dict{Any,V}(zip(ks, vs))
@deprecate Dict(ks, vs) Dict{Any,Any}(zip(ks, vs))

@deprecate itrunc{T<:Integer}(::Type{T}, n::Integer) (n % T)
Expand Down
14 changes: 7 additions & 7 deletions base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ copy(d::Dict) = Dict(d)
const AnyDict = Dict{Any,Any}

# TODO: this can probably be simplified using `eltype` as a THT (Tim Holy trait)
Dict{K,V}(kv::Tuple{Tuple{K,V},...}) = Dict{K,V}(kv)
Dict{K }(kv::Tuple{Tuple{K,Any},...}) = Dict{K,Any}(kv)
Dict{V }(kv::Tuple{Tuple{Any,V},...}) = Dict{Any,V}(kv)
Dict{K,V}(kv::Tuple{Pair{K,V},...}) = Dict{K,V}(kv)
Dict{K} (kv::Tuple{Pair{K},...}) = Dict{K,Any}(kv)
Dict{V} (kv::Tuple{Pair{TypeVar(:K),V},...}) = Dict{Any,V}(kv)
Dict (kv::Tuple{Pair,...}) = Dict{Any,Any}(kv)
Dict{K,V}(kv::Tuple{Vararg{Tuple{K,V}}}) = Dict{K,V}(kv)
Dict{K }(kv::Tuple{Vararg{Tuple{K,Any}}}) = Dict{K,Any}(kv)
Dict{V }(kv::Tuple{Vararg{Tuple{Any,V}}}) = Dict{Any,V}(kv)
Dict{K,V}(kv::Tuple{Vararg{Pair{K,V}}}) = Dict{K,V}(kv)
Dict{K} (kv::Tuple{Vararg{Pair{K}}}) = Dict{K,Any}(kv)
Dict{V} (kv::Tuple{Vararg{Pair{TypeVar(:K),V}}}) = Dict{Any,V}(kv)
Dict (kv::Tuple{Vararg{Pair}}) = Dict{Any,Any}(kv)

Dict{K,V}(kv::AbstractArray{Tuple{K,V}}) = Dict{K,V}(kv)
Dict{K,V}(kv::AbstractArray{Pair{K,V}}) = Dict{K,V}(kv)
Expand Down
21 changes: 18 additions & 3 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ function abstract_apply(af, fargs, aargtypes::Vector{Any}, vtypes, sv, e)
if is(aat.name, tn)
et = aat.parameters[1]
if !isa(et,TypeVar)
return Tuple{et, ...}
return Tuple{Vararg{et}}
end
end
if is(aat, Any)
Expand Down Expand Up @@ -3236,9 +3236,16 @@ function replace_getfield!(ast, e::ANY, tupname, vals, sv, i0)
end
end

code_typed(f, types::ANY; optimize=true) =
function code_typed(f, types::ANY; optimize=true)
if isa(types,Tuple)
types = Tuple{types...}
end
code_typed(call, Tuple{isa(f,Type)?Type{f}:typeof(f), types.parameters...}, optimize=optimize)
end
function code_typed(f::Function, types::ANY; optimize=true)
if isa(types,Tuple)
types = Tuple{types...}
end
asts = []
for x in _methods(f,types,-1)
linfo = func_for_method(x[3],types,x[2])
Expand All @@ -3256,8 +3263,16 @@ function code_typed(f::Function, types::ANY; optimize=true)
asts
end

return_types(f, types::ANY) = return_types(call, Tuple{isa(f,Type)?Type{f}:typeof(f), types.parameters...})
function return_types(f, types::ANY)
if isa(types,Tuple)
types = Tuple{types...}
end
return_types(call, Tuple{isa(f,Type)?Type{f}:typeof(f), types.parameters...})
end
function return_types(f::Function, types::ANY)
if isa(types,Tuple)
types = Tuple{types...}
end
rt = []
for x in _methods(f,types,-1)
linfo = func_for_method(x[3],types,x[2])
Expand Down
2 changes: 1 addition & 1 deletion base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ read(s::IO, ::Type{Float64}) = box(Float64,unbox(Int64,read(s,Int64)))

read{T}(s::IO, t::Type{T}, d1::Int, dims::Int...) = read(s, t, tuple(d1,dims...))
read{T}(s::IO, t::Type{T}, d1::Integer, dims::Integer...) =
read(s, t, convert(Tuple{Int,...},tuple(d1,dims...)))
read(s, t, convert(Tuple{Vararg{Int}},tuple(d1,dims...)))

read{T}(s::IO, ::Type{T}, dims::Dims) = read!(s, Array(T, dims))

Expand Down
2 changes: 1 addition & 1 deletion base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ end

# It's most efficient to call checkbounds first, then to_index, and finally
# allocate the output. Hence the different variants.
_getindex(A, I::Tuple{Union(Int,AbstractVector), ...}) =
_getindex(A, I::Tuple{Vararg{Union(Int,AbstractVector),}}) =
_getindex!(similar(A, index_shape(I...)), A, I...)

# The stagedfunction here is just to work around the performance hit
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/resolve/versionweight.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ end

const _vwprebuild_zero = VWPreBuild(0, HierarchicalValue(VWPreBuildItem))

function VWPreBuild(ispre::Bool, desc::Tuple{Union(Int,ASCIIString),...})
function VWPreBuild(ispre::Bool, desc::Tuple{Vararg{Union(Int,ASCIIString)}})
isempty(desc) && return _vwprebuild_zero
desc == ("",) && return VWPreBuild(ispre ? -1 : 1, HierarchicalValue(VWPreBuildItem[]))
nonempty = ispre ? -1 : 0
Expand Down
2 changes: 1 addition & 1 deletion base/pointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function pointer_to_array{T,N}(p::Ptr{T}, dims::NTuple{N,Integer}, own::Bool=fal
end
i += 1
end
pointer_to_array(p, convert(Tuple{Int,...}, dims), own)
pointer_to_array(p, convert(Tuple{Vararg{Int}}, dims), own)
end
unsafe_load(p::Ptr,i::Integer) = pointerref(p, Int(i))
unsafe_load(p::Ptr) = unsafe_load(p, 1)
Expand Down
2 changes: 1 addition & 1 deletion base/promotion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ end
function promote(x, y, zs...)
(convert(promote_typeof(x,y,zs...), x),
convert(promote_typeof(x,y,zs...), y),
convert(Tuple{promote_typeof(x,y,zs...),...}, zs)...)
convert(Tuple{Vararg{promote_typeof(x,y,zs...)}}, zs)...)
end
# TODO: promote{T}(x::T, ys::T...) here to catch all circularities?

Expand Down
10 changes: 5 additions & 5 deletions base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,16 @@ globalRNG() = GLOBAL_RNG
@inline rand(T::Type) = rand(GLOBAL_RNG, T)
rand(::Tuple{}) = rand(GLOBAL_RNG, ()) # needed to resolve ambiguity
rand(dims::Dims) = rand(GLOBAL_RNG, dims)
rand(dims::Integer...) = rand(convert(Tuple{Int,...}, dims))
rand(dims::Integer...) = rand(convert(Tuple{Vararg{Int}}, dims))
rand(T::Type, dims::Dims) = rand(GLOBAL_RNG, T, dims)
rand(T::Type, d1::Integer, dims::Integer...) = rand(T, tuple(Int(d1), convert(Tuple{Int,...}, dims)...))
rand(T::Type, d1::Integer, dims::Integer...) = rand(T, tuple(Int(d1), convert(Tuple{Vararg{Int}}, dims)...))
rand!(A::AbstractArray) = rand!(GLOBAL_RNG, A)

rand(r::AbstractArray) = rand(GLOBAL_RNG, r)
rand!(A::AbstractArray, r::AbstractArray) = rand!(GLOBAL_RNG, A, r)

rand(r::AbstractArray, dims::Dims) = rand(GLOBAL_RNG, r, dims)
rand(r::AbstractArray, dims::Integer...) = rand(GLOBAL_RNG, r, convert(Tuple{Int,...}, dims))
rand(r::AbstractArray, dims::Integer...) = rand(GLOBAL_RNG, r, convert(Tuple{Vararg{Int}}, dims))

## random floating point values

Expand Down Expand Up @@ -255,10 +255,10 @@ rand{T<:Real}(r::AbstractRNG, ::Type{Complex{T}}) = complex(rand(r, T), rand(r,
## Arrays of random numbers

rand(r::AbstractRNG, dims::Dims) = rand(r, Float64, dims)
rand(r::AbstractRNG, dims::Integer...) = rand(r, convert(Tuple{Int,...}, dims))
rand(r::AbstractRNG, dims::Integer...) = rand(r, convert(Tuple{Vararg{Int}}, dims))

rand(r::AbstractRNG, T::Type, dims::Dims) = rand!(r, Array(T, dims))
rand(r::AbstractRNG, T::Type, d1::Integer, dims::Integer...) = rand(r, T, tuple(Int(d1), convert(Tuple{Int,...}, dims)...))
rand(r::AbstractRNG, T::Type, d1::Integer, dims::Integer...) = rand(r, T, tuple(Int(d1), convert(Tuple{Vararg{Int}}, dims)...))
# note: the above method would trigger an ambiguity warning if d1 was not separated out:
# rand(r, ()) would match both this method and rand(r, dims::Dims)
# moreover, a call like rand(r, NotImplementedType()) would be an infinite loop
Expand Down
4 changes: 2 additions & 2 deletions base/range.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 1-dimensional ranges ##

typealias Dims Tuple{Int,...}
typealias Dims Tuple{Vararg{Int}}

abstract Range{T} <: AbstractArray{T,1}

Expand Down Expand Up @@ -241,7 +241,7 @@ logspace(start::Real, stop::Real, n::Integer=50) = 10.^linspace(start, stop, n)

## interface implementations

similar(r::Range, T::Type, dims::Tuple{Integer,...}) = Array(T, dims...)
similar(r::Range, T::Type, dims::Tuple{Vararg{Integer}}) = Array(T, dims...)
similar(r::Range, T::Type, dims::Dims) = Array(T, dims)

size(r::Range) = (length(r),)
Expand Down
Loading

0 comments on commit dccb99c

Please sign in to comment.