Closed stevengj closed 6 years ago
Oh, I was a little confused by your example, showing the ele.data
dictionary. It seems that you have both a struct and a dictionary. Why keep the data
dictionary around at all? Seems better to store the information in only one way.
Also, I notice that all of your element fields are untyped. Better to give them all concrete types.
(You might want a mutable struct
so that returning it doesn't need to make a copy, and can just return a pointer.)
Instead of a
Dict{String,Any}
, it seems like it would be better to return a customElement
type with typed fields likenumber
,name
, and so on.The basic reason for this is that defining an
Element
type will provide the information about the fields and their types to the Julia compiler. Otherwise you are forcing any computation that uses element data to be type-unstable.