Skip to content

Instantly share code, notes, and snippets.

@carlobaldassi
Created March 21, 2012 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlobaldassi/2142899 to your computer and use it in GitHub Desktop.
Save carlobaldassi/2142899 to your computer and use it in GitHub Desktop.
julia: problematic convesion to Vector{Tuple}
typealias MyTuple (ASCIIString, BitsKind)
type MyType
some_field::Int
function MyType(vec::Vector{MyTuple})
println("INNER")
new(0)
end
end
function MyType(vec)
println("OUTER")
println(" eltype pre=$(eltype(vec))")
c_vec = convert(Vector{MyTuple}, vec) ## this conversion doesn't work!
println(" eltype post=$(eltype(c_vec))")
MyType(c_vec)
end
some_data = [("a", Int32), ("b", Int32)]
some_c_data = convert(Vector{MyTuple}, some_data) ## conversion works here
ex_c_data = MyType(some_c_data) ## <- this works
#ex_data = MyType(some_data) ## <- this keeps calling the
## outer constructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment