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 take a reasonable default. 

# define the type
type foo{T<:Number, S<:Integer}
    x::Vector{T}
    y::Vector{S}
    isfoo::Bool
    # default constructor does not take arguments, and 
    # initialises the internal fields appropriately.
    foo() = new(T[], S[0], true)
end

# with default constructor you must specify all parameters
f = foo{Int64, Int32}()

# want to define a constructor with default second parameter, e.g.:
foo{T}() = foo{T, Int32}()

# in order to do things like
b = foo{Int64}()

The extra method definition results in the error

WARNING: static parameter T does not occur in signature for call at none:1.
The method will not be callable.
foo{T,S}

and the constructor cannot be of course utilised. 

Does julia allow anything like this? It might not be possible at all, so I 
am interested in ways to achieve the same end in a different way.

Thanks

Reply via email to