...inside the type declaration you don't put the {T} on the method declarations. I'm not sure what this does, but the inner {T} might shadow the outer {T}. What you want is this:julia> type Doh{T}a::TDoh() = new()end
julia> doh = Doh{Int64}();So inside of the type declaration scope, Doh is like Doh{T} outside because T is already bound as a universal quantifier by the type block.
DataVec{T}(data::Vector{T}, na::BitVector) = DataVec{T}(data, na)
DataVec([1, 2, 3], bitpack([false, false, false]))
--
--
This may be of no use to others, but the thing I find absolutely bewildering is that removing our custom inner constructor doesn't fix my problem, but it does mean that the following starts to work:DataVec([1, 2, 3], [false, false, false])-- John
On Dec 5, 2012, at 6:25 PM, Stefan Karpinski <ste...@karpinski.org> wrote:
----
julia> type Foo1{T}x::Tendjulia> Foo1(1)Foo1{Int64}(1)julia> type Foo2{T}x::TFoo2(x) = new(x)endjulia> Foo2(1)no method Foo2(Int64,)
in method_missing at base.jl:81
--
--
--
--
--
--Tim
--
type Foo2{T<:Real}x::TFoo2(n::T) = new(n)end
julia> methods(Foo2{Int})# methods for generic function Foo2Foo2(n::Int64) at none:3julia> methods(Foo2)# methods for generic function Foo2
Foo2{T<:Real}(x::T) = Foo2{T}(x)
julia> methods(Foo2)# methods for generic function Foo2Foo2{T<:Real}(x::T<:Real) at none:1
That clarifies the behavior quite a lot, in particular that the inner constructor is like a field declaration. I didn't guess this solution from the manual though. Thanks!