-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
types and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch
Description
I may be dense here, but on older julias (pre #10380?) one can do this:
julia> foo{T<:FloatingPoint}(t::(String,Type{T})) = 1
foo (generic function with 1 method)
julia> foo(("hi",Float32))
1
julia> foo(("hi",Int))
ERROR: `foo` has no method matching foo(::(ASCIIString,DataType))but on current 0.4
julia> foo{T<:FloatingPoint}(t::Tuple{AbstractString,Type{T}}) = 1
foo (generic function with 1 method)
julia> foo(("hi",Float32))
ERROR: MethodError: `foo` has no method matching foo(::Tuple{ASCIIString,DataType})
Closest candidates are:
foo{T<:FloatingPoint}(::Tuple{AbstractString,Type{T<:FloatingPoint}})One can do
julia> foo(t::Tuple{AbstractString,DataType}) = _foo(t[1], t[2])
foo (generic function with 1 method)
julia> _foo{T<:FloatingPoint}(filename::AbstractString, ::Type{T}) = 1
_foo (generic function with 1 method)but it's not quite as convenient. Bug, or just the way it's gonna be?
I have formerly used the (filename, T) construct as a way of signaling to algorithms that they should use mmap_array rather than Array for allocating their output (because the output will be too big otherwise).
Metadata
Metadata
Assignees
Labels
types and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch