JLD.jl
JLD.jl copied to clipboard
should has(jld,name) work?
Consider
jld = jldopen("test.jld","w")
jld["a"]=1
has(jld,"a") # ERROR: MethodError: `has` has no method ...
has(jld.plain,"a")
Is there a reason this doesn't work?
You're looking for haskey, not has. But yes, it would be nice if this worked, so that jld behaved like an associative structure.
Is there a reason this doesn't work?
No good reason.
I first looked for haskey. But I posted about has because that works for the plain HDF5File. I'm happy to try to add this.
It seems like JLDFile (and HDF5File) should are kind of emulating an associative like Dict, but with many deviations. . What would you think about doing the following for both JLDFile and HDF5File (in HDF5.jl of course):
- Add
haskey - Add
keysmethods that do the same thing asnames(jld)
It's worth thinking a bit more about how exactly JLDFile is similar to a Dict and how it isn't.
Probably a lot of the deviations are due to the fact that these packages date from the julia 0.2 days.
In general I'd say it would be best if it emulated the Dict interface wherever it makes sense. At the moment, I'm failing to think of a way in which it shouldn't act like a Dict.