Say I have the following code
axisnames = (:first, :second, :third, :fourth, :fifth, :sixth)
function CartesianCoordinates(t::Vararg{T, N}) where {N, T <: Real}
NamedTuple{tuple(axisnames[1:N]...), NTuple{N, T}}((t))
end
That is, a NamedTuple
can be constructed with up to 6 names. But I
want to make CartesianCoordinates
a type, not a function. Because
I want to let the user just sees CartesianCoordinates
when printing/showing,
not a NamedTuple
. At the same time, I want it to be used as a NamedTuple
,
so that I can directly use many predefined methods for NamedTuple
, without writing them
myself.
In brief, what I want is a “super” type alias MyType
(implemented by a PredefinedType
), i.e., with a constructor, and shown as MyType
itself.
How can I do that?