This is invariance striking. There should probably a FAQ entry for this as it is often discussed: https://groups.google.com/forum/#!searchin/julia-users/invariance
Docs: http://docs.julialang.org/en/release-0.3/manual/types/#parametric-composite-types On Tue, 2015-08-18 at 09:37, Kevin Kunzmann <[email protected]> wrote: > Hi guys, > > So, I recently revisited Julia and fooled around a bit with Julia Box. > Amazing - this looks like the language I never actually dared dreaming of > ;) Keep up the greedy work! > > That being said, my question might be dumb, but I am struggling with the > type system of Julia. I want to guarantee that the arguments to a function > are numerical arrays of dimension 1 - how would I best do that in Julia? > The problem is that > > Array{Number, 1} > > exists as a type, but when I get the type system right it should not have > any subtypes except union. Especially > > Array{Float64, 1} <: Array{Number, 1} > > evaluates to ' false'. I think I get why this is implemented the way it is, > however, would it not be most intuitive to have something like > > function f(x::Array{Number, 1}) > x > end > > > What would be the 'Julian' way of doing this? function f{T<:Number}(x::Array{T, 1}) x end
