You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to make compound abstract typed function parameters work?
I would like to declare and invoke a function like this:
function foo(x::Associative{Symbol, AbstractArray{Number}})
x
end
d = Dict(:a=>[1,2,3], :b=>[4,5,6])
foo(d)
foo(d) currently throws an error since typeof(d) is Dict{Symbol,Array{Int64,1}} and it is not a subtype of Associative{Symbol, AbstractArray{Number}}. This subtype behavior does not have to change.
Instead, when foo(d) is invoked, Julia could internally define and compile a method called foo for Dict{Symbol, Array{Int64,1}} and invoke this method.
The text was updated successfully, but these errors were encountered:
We can't yet fully express the constraints you want, but this comes close:
function foo{A<:AbstractArray}(x::Associative{Symbol, A})
The full version you want is basically #6984, and will be implemented by #8974.
As for method selection and specialization, you have the order of events slightly wrong: first we look up which method to use, so the method has to match first of all. Then we compile a specialization and invoke it.
Is it possible to make compound abstract typed function parameters work?
I would like to declare and invoke a function like this:
foo(d)
currently throws an error sincetypeof(d)
isDict{Symbol,Array{Int64,1}}
and it is not a subtype ofAssociative{Symbol, AbstractArray{Number}}
. This subtype behavior does not have to change.Instead, when
foo(d)
is invoked, Julia could internally define and compile a method calledfoo
forDict{Symbol, Array{Int64,1}}
and invoke this method.The text was updated successfully, but these errors were encountered: