Hi, 

I am starting with julia and stumbled upon this issue. Say I want to define 
this composite type

type MyType
   data::Array{Float64, 1}
   meta::Dict{ASCIIString, Number}
   N::Int64
end
where the data field will store some floats, meta will be a dict of 
metadata (from a simulation), and N is some other number storing the size 
of data (just a silly example).

Say I define another constructor as:
MyType(data::Array{Float64, 1}, meta::Dict{ASCIIString, Number}) = MyType(
data, meta, size(data))


If I then create an instance with the default constructor I get the 
expected behaviour:
MyType(zeros(Float64, 5), ["param"=>2], 5)

"MyType([0.0,0.0,0.0,0.0,0.0],["param"=>2], 5)"


However, if I use the additional constructor I obtain a 
MyType(zeros(Float64, 5), ["param"=>2.0])

"no method MyType(Array{Float64,1}, Dict{ASCIIString,Float64})
while loading In[4], in expression starting on line 1"



As far as I understand, by reading the documentation regarding parametric 
composite types, the error is raised because Dict{ASCIIString, Float64} is 
not a subtype of Dict{ASCIIString, Number}.

What is the approach to cope with this problem?

Thanks, 

Davide

Reply via email to