[julia-users] Re: Julia 0.4.0-rc4 abstract types in functional signatures don't seem to work

2015-10-08 Thread lewis
Thanks Tomas, but what you are saying seems to violate the manual. Here is the verbatim example: (from Chapter 12, "Methods", page 104) As you can see, the arguments must be precisely of type Float64. Other numeric types, such as integers or 32- bit floating-point values, are not

[julia-users] Re: Julia 0.4.0-rc4 abstract types in functional signatures don't seem to work

2015-10-08 Thread Tomas Lycken
This is well documented behavior, and has been the same since “forever” (it’s a fundamental design decision in Julia’s type system). The manual section on parametric types talks quite a lot about this, including

[julia-users] Re: Julia 0.4.0-rc4 abstract types in functional signatures don't seem to work

2015-10-08 Thread Tomas Lycken
You’re reading the wrong part of the manual :) The missing piece of the puzzle is that, from your example, Array{Float64,1} <: Array{Real,1} is *not true*, and therefore, the invocation p(2.3, [1, 1.5]) *does not* match the method definition p(x::Real, coef::Array{Real,1}); the first

[julia-users] Re: Julia 0.4.0-rc4 abstract types in functional signatures don't seem to work

2015-10-08 Thread Kristoffer Carlsson
There is a difference between an abstract type like Number and a type parameterized by an abstract types like Vector{Number}. While it is true that for example Float64 is a subtype of Number it is not true that Vector{Float64} is a subtype of Vector{Number}. On Thursday, October 8, 2015 at

[julia-users] Re: Julia 0.4.0-rc4 abstract types in functional signatures don't seem to work

2015-10-08 Thread lewis
Yup. Thanks Kristoffer. I did a few more little things in julia and figured it out before I saw your post: function(x::Real, y::Real) return 2x - y end function(x::Real, y::Array{Real, 1}) return 2x - y[1] end First one works; second one does not. It is the use of Array, a compound

[julia-users] Re: Julia 0.4.0-rc4 abstract types in functional signatures don't seem to work

2015-10-08 Thread vavasis
I'd like to point out that the fact that Array{Float64,1} is not a subtype of Array{Any,1} makes it easier to reason about Julia program correctness and therefore avoid errors. Consider: function f(a::Array{Any,1}) push!(a, "hello") end Is this function correct? Assuming I didn't make