Hello,
and as always, thanks in advance for taking the time to read this post and help me out.
I’m back to toying around with (and hopefully learning) Julia. In order to get a better feel for the type system and the possibilities that the language offers, I’ve decided to implement a subtype tree printer (probably a fairly common thing for novices to do).
This is working fine, but it’s not showing all the info I’d like. Specifically, when a type takes parameters, it doesn’t list them; and when there’s aliases for a type, those don’t show up either.
To illustrate what I mean, let’s consider Array
.
This type takes two parameters, and I’d like for my function to show something like Array{T, N}
or Array{T, N} where {T, N}
instead of just Array
for the node in question. When I have some type for which I don’t know whether it has parameters, how many there are or what they are, how do I get this information programmatically?
Furthermore, there’s aliases: Vector{T}
is an alias for Array{T, 1}
, and Matrix{T}
is an alias for Array{T, 2}
, and I’d like to include these in my tree in a similar manner as I would include subtypes of Array
(possibly in a way that’s visually distinct from true subtypes, but that’s another matter). To do this, I’d have to get all such aliases in a programmatic manner, but again — if I have some arbitrary type, how do I tell if there are aliases for what I’m tempted to call specializations of this type?
(And JBTW, I know there’s other tools for visualizing the Julia type tree already. I am trying to reinvent the wheel on purpose here — I believe that doing so, solving the problems you run into along the way, and asking for help when you encounter a problem you can’t solve is a great way to learn.)
I checked for relevant questions, performed a web search and also skimmed through the Julia documentation, but did not find anything apropos.
Thank you & all the best!
Chris