Closed sefffal closed 2 years ago
Cool. I think a compact syntax for this would be great. Colon seems a little weird, since I'd expect header["key", :]
to return a 1-d array, in analogy with other data structures (like 2-d Arrays). I was wondering if using a special symbol value like header["key", :comment]
would be more explicit?
Or perhaps something like header[“key”, !]
if we want to really differentiate it from slice indexing (or any other small symbol function like ^, *, +, <, etc) without writing out “:comment”.
Why not passing a tuple (val, com)
with the value and comment instead of just val
when you just want to change the value? This is what I have done in EasyFITS.jl (an attempt to simplify dealing with FITS files).
I think that creates an asymmetry in design, because that would only work with `setindex!’, we still need a way to get the comment out using some compact notation
OK then back to the previous suggestion, why not with an additional /
after the key as a reminder that this symbol is the value-comment separator in FITS header?
Good points about the colon, it is a bit odd. I like the /
suggestion since it looks like a FITS comment.
Would we use it for directly accessing the comment (not a value and comment tuple)?
e.g.
header["KEY"] = 1
header["KEY", /] = "comment"
Hi all, Thanks for this package.
Here is an idea and implementation for a compact syntax for getting and setting header values and comments at the same time:
This was done by overriding
getindex
andsetindex!
for the colon argument. If this is interesting, I would be happy to add tests etc.Thanks for reading!