Closed ericphanson closed 2 years ago
I used Base.merge_names here... to have a fast way of merging the tuples of symbols without duplicates
I think this is the same motivation as for the hack NamedDims.jl uses to make operations on tuples of symbols non-allocating
https://github.com/invenia/NamedDims.jl/blob/77b09418820bca221d5bff68eacd613a8bfac6ed/src/name_core.jl#L10-L30
Anyway, using Base.merge_names
seems fine to me. But then again, i suspect propertynames(x; private=true)
being slow/allocating seems fine too.
Closes #131
Here, I define the "public" properties as the
getproperty
overloads, and the private properties as any remaining internal fields. My thinking is then downstream types can accept this or define their ownpropertynames
to declare which fields whey want to be private or not.I used
Base.merge_names
here; this is a Julia internal function so perhaps we should not depend on it. It has at least existed for 4 years (https://github.com/JuliaLang/julia/blame/ff001a4e1f5b7f949f5a2328520a7e78bc1957b4/base/namedtuple.jl#L211). The reason I wanted to use it is to have a fast way of merging the tuples of symbols without duplicates (a slow alternative would beTuple(unique((public_names..., fieldnames(T)...)))
).