[julia-users] extra constructor with optional, default value for second parameter?

2016-04-17 Thread Davide Lasagna
Hi, I am defining a type with two parameters, see code below as a demonstration. I can, of course, use the default constructor with all parameters explicitly specified. However, I would like to have an extra constructor in which I have to specify only the first parameter, and have the second

Re: [julia-users] extra constructor with optional, default value for second parameter?

2016-04-17 Thread Mauro
I wrote about this a few days ago: https://groups.google.com/d/msg/julia-users/jUMu9A3QKQQ/-ZShKvLXAwAJ It's inner vs outer constructors. Basically you have to pass in the type as a normal function argument, like e.g. `Array(Int,3)` does, or use `call` overloading: julia> Array{Int}(3) 3-element

Re: [julia-users] extra constructor with optional, default value for second parameter?

2016-04-17 Thread Davide Lasagna
Thanks Mauro. I though about passing the extra type as a normal function argument, but did not like it as it was pretty much equivalent to specifying the parameter in the first place. Using the call overload is a nice trick: call{T}(::Type{foo{T}}) = foo{T, Int32}() which let me define new `f