[julia-users] Re: Array construction types question
It's very helpful to note what your expected result is when asking a question like this--I'm not clear what isn't working as expected, here. As far as I can tell all the inferred types are correct, though the second one and the final one could be narrower. On Wednesday, April 1, 2015 at 10:02:37 AM UTC-5, Michael Francis wrote: If I run the following, I get the results show to the right (in comments), it appears array construction fails to raise to the common parent type under certain conditions, is there a way round this? Alternatively where is this code implemented ? abstract Foo{K} type Wow{K,V} : Foo{K} end type Bar{K,V} : Foo{K} end a = Wow{Int64, Int64}() b = Wow{Int64, Float64}() c = Bar{Int64, Int64}() d = Bar{Int64, String}() println( ** ) println( typeof( [ a ])) #Array{Wow{Int64,Int64},1} println( typeof( [ a, b ])) #Array{Wow{K,V},1} println( typeof( [ a, c ])) #Array{Foo{Int64},1} println( typeof( [ a, b, c ]))#Array{Foo{Int64},1} println( typeof( [ a, c, b ]))#Array{Foo{Int64},1} println( typeof( [ a, b, c, d ])) #Array{Foo{K},1}
Re: [julia-users] Re: Array construction types question
The K and V here are typevars – printing Wow as Wow{K,V} is just to indicate that the type takes two type parameters. Arguably, it might be better to just print this type as Wow. On Wed, Apr 1, 2015 at 11:31 AM, Michael Francis mdcfran...@gmail.com wrote: Sorry, To be clear you should never see K or V in the type, it looks as though it is widening to the parameter free version of the abstract type. On Wednesday, April 1, 2015 at 11:18:38 AM UTC-4, Patrick O'Leary wrote: It's very helpful to note what your expected result is when asking a question like this--I'm not clear what isn't working as expected, here. As far as I can tell all the inferred types are correct, though the second one and the final one could be narrower. On Wednesday, April 1, 2015 at 10:02:37 AM UTC-5, Michael Francis wrote: If I run the following, I get the results show to the right (in comments), it appears array construction fails to raise to the common parent type under certain conditions, is there a way round this? Alternatively where is this code implemented ?
[julia-users] Re: Array construction types question
Sorry, To be clear you should never see K or V in the type, it looks as though it is widening to the parameter free version of the abstract type. On Wednesday, April 1, 2015 at 11:18:38 AM UTC-4, Patrick O'Leary wrote: It's very helpful to note what your expected result is when asking a question like this--I'm not clear what isn't working as expected, here. As far as I can tell all the inferred types are correct, though the second one and the final one could be narrower. On Wednesday, April 1, 2015 at 10:02:37 AM UTC-5, Michael Francis wrote: If I run the following, I get the results show to the right (in comments), it appears array construction fails to raise to the common parent type under certain conditions, is there a way round this? Alternatively where is this code implemented ?