JuliaCloud / XMLDict.jl

XMLDict implements a simple Associative interface for XML documents.
Other
33 stars 11 forks source link

doesn't support keys, etc. #8

Closed stevengj closed 7 years ago

stevengj commented 7 years ago

Currently, it XMLDict doesn't seem to support lots of the Associative interface. e.g. keys(xml) doesn't work.

samoconnor commented 7 years ago

Thanks for pointing this out @stevengj. Do you have any thoughts on the best way to implement this? Is there a specification for the minimal set of functions needed to implement Associative? (It isn't immediatly clear to me from this: https://docs.julialang.org/en/stable/stdlib/collections/?highlight=associative#associative-collections )

Should there be fall-backs in base so that custom types don't have to implement everything ? e.g. keys(x) = [k for (k,v) in x]

stevengj commented 7 years ago

There is a fallback keys definition. But it breaks when you try to display it because you haven't implemented length.

I would just look at https://github.com/JuliaLang/julia/blob/master/base/associative.jl and see what methods are defined for e.g. ObjectIdDict vs. Associative

Note that if you define length and maybe some other methods, then you won't need to define show at all (the default show method for Associative will work).

samoconnor commented 7 years ago

Hi @stevengj, I've had a go at addressing this. I've added keys, length, start, done, and next.

stevengj commented 7 years ago

Thanks!