[julia-users] Composite type fields and types defined

2014-03-01 Thread Ben Ward


Hi,

Is there a way to extract the names and types of the fields in a given 
composite type? 

Say:

type MyType
 a::Int
end

Is there a way to get the field 'a', and the type of the field Int? I think 
I've seen a way to get the type in the manual but not the name assigned to 
the field.

And also how do I list all the types defined in a module? I'm planning on 
attempting to use Julia's metaprogramming features for a task where I need 
to know these things.

Thanks,
Ben.


Re: [julia-users] Composite type fields and types defined

2014-03-01 Thread Ben Ward
Thanks Mauro!

On Saturday, March 1, 2014 8:40:31 AM UTC, Mauro wrote:

 have a look at 
 http://docs.julialang.org/en/release-0.2/stdlib/base/#reflection 

 This works 
 MyType.names 
 MyType.types 

 there is also the names function.  Don't know if there is a 
 corresponding 'types' function.  Incidentally names also list all names 
 defined in a module. 

 On Sat, 2014-03-01 at 08:27, axolotl...@gmail.com javascript: wrote: 
  Hi, 
  
  Is there a way to extract the names and types of the fields in a given 
  composite type? 
  
  Say: 
  
  type MyType 
   a::Int 
  end 
  
  Is there a way to get the field 'a', and the type of the field Int? I 
 think 
  I've seen a way to get the type in the manual but not the name assigned 
 to 
  the field. 
  
  And also how do I list all the types defined in a module? I'm planning 
 on 
  attempting to use Julia's metaprogramming features for a task where I 
 need 
  to know these things. 
  
  Thanks, 
  Ben.