How would one determine the nominal type of a field in a composite type?
For example, suppose I have something like this:
mutable struct MyType sub::Number end function foo(x::Any) # I can get the type of whatever is stored in "sub" like so: typeof(x.sub) # For our example, this returns Float64, not Number # But suppose I want to know what 'sub' is allowed to be, # like is it always a Float64? Or a Number? Or an Any? end x = MyType(2.7); foo(x) # I'd like this to return Number, not Float64.
More generally, how do I explore the type MyType?
(While we’re here, is there some way to declare that the input “x” must have a field called “sub” without specifying any particular abstract type?)
This if for a some flexible conversion utilities where performance is totally unimportant.