There are plans, to integrate this as an default constructor:
https://github.com/JuliaLang/julia/issues/5333
Best is to write the constructor yourself, to have the correct defaults ;)
By the way, your type is not designed very well, as you're using abstract 
field types.
Better would be:

type Parameters{RealT <: Real, RangeT <: FloatRange}
 sigma::RealT
 xi::RealT
 eta::RealT
 beta::RealT
 rho::RealT
 agrid::RangeT
end

see: http://julia.readthedocs.org/en/latest/manual/performance-tips/ 
 => Avoid containers with abstract type parameters


Am Samstag, 17. Januar 2015 01:34:19 UTC+1 schrieb Andrew:
>
> Suppose I have a model which contains many parameters. I'd like to store 
> my parameters in a type, for example
>
> type Parameters
>  sigma::Real
>  xi::Real
>  eta::Real
>  beta::Real
>  rho::Real
>  agrid::FloatRange
> end
>
>
> and then I need to assign some values to my parameters. The natural way I 
> see to do this is
>
> params = Parameters(1,2,3,4,5,linrange(1,10,10))
>
>
>
> or something like that. However, the fact that I need to remember the 
> order in which I defined these parameters means there is some chance of 
> error. In reality I have about 20 parameters, so defining them this way 
> would be quite annoying.
>
> It would be nice if there was a constructor that would let me use keyword 
> arguments, as in
>
> params = Parameters(sigma=1,xi=2,eta=3,beta=4,rho=5,agrid=linrange(1,10,10
> )) .
>
>
>
> I know I could write my own constructor and use keyword arguments, but 
> then I think I'd still need to use the ordered constructor to write that 
> one.
>
> Is there an easy way to do this? Maybe a macro that could automatically 
> define a constructor with keyword arguments?(I don't know much about 
> metaprogramming). Alternatively, is there is a cleaner way to store 
> parameters that doesn't use types?
>
> ---
> I did find a related post here. 
> https://groups.google.com/forum/#!searchin/julia-users/constructor$20keyword$20arguments/julia-users/xslxrihfO30/jV2awP5tbpEJ
>  
> . Someone suggests that you can define a constructor like,
> Foo(;bar=1, baz=2) = new(bar, baz)
>
> which does what I want. Is there a way to macro that so that it's 
> automatically defined for every field in the type?
>

Reply via email to