That wouldn’t work properly as Julia does not dispatch on keyword arguments (see discussion How can kwargs be used in multiple dispatch - #2 by lmiq).
In this particular case, it is not too cumbersome to check all variants of missing
ness of two kwargs, so I personally would go with that.
On the other hand, I agree that, unless my_struct
is mutable, a partially-filled case may just be another type. It is even possible to overload getproperty
so that .a
-.e
access would give missing
, although I’d prefer accessor functions for that.
function Base.getproperty(x::my_partial_struct, p::Symbol)
if p in (:a, :b, :c, :d, :e)
return missing
else
return getfield(x, p)
end
end