DataStructures.jl
DataStructures.jl copied to clipboard
cons does not create list of supertype
Apologies if this is due to my lack of understanding (I am relatively new to Julia) but it would be useful if the list constructor promoted subtypes in the same way as the base data collections seem to. In particular, below you can see that the element type of the LinkedList is "Any" whereas the element type of the Array is "Int64".
typeof(list(Int32(1), Int64(1)))
typeof([Int32(1), Int64(1)])
Yes, adding this would be a nice feature.
Probably could be done by using the promote machinery to promote everything to a common type before construting the nil
Change would need to be made around this point in the code
https://github.com/JuliaCollections/DataStructures.jl/blob/e3c9c5698415e3c65d5a11255680c72e23927234/src/list.jl#L45
Implemented in https://github.com/JuliaCollections/DataStructures.jl/pull/685