An example with the Complex type:

julia> Complex.types
(T<:Real,T<:Real)

julia> Complex.names
(:re,:im)

These fields are defined for all DataTypes (including abstract types and 
bits types), though for non-composite types they are an empty tuple. A 
UnionType will have no field names, and the types field will be a tuple of 
all types in the union. In parametric types, the elements of the types 
array for fields whose types are parameterized are of type TypeVar. Check 
out names(DataType) for other fields that give you all you'd need to 
reconstruct any DataType with a macro or something.


On Friday, 17 January 2014 19:45:46 UTC-6, John Myles White wrote:
>
> I don’t know offhand how to do this, but I’d look at the code for xdump, 
> which shows that the necessary introspection operations exist: 
>
> Foo::DataType  <: Any 
>   a::Int64::DataType  <: Signed 
>   b::Float64::DataType  <: FloatingPoint 
>
>  — John 
>
> On Jan 17, 2014, at 10:16 AM, Simon Byrne <[email protected]<javascript:>> 
> wrote: 
>
> > I want to define a new composite type with exactly the same fields as 
> another type. Is there an easy way to do this? The original type is not 
> parametric. 
> > 
> > Alternatively, is there a way I can figure out the type of a field of a 
> composite type Foo without constructing an object of type Foo? 
> > 
> > -Simon 
>
>

Reply via email to