The line: a[:] = [Int64, Float32]
Sets the values of the elements of a[] but does not change its type. (Don't be misled by the printout after the line, its the right hand side of the assignment, not a) Cheers Lex On Saturday, October 10, 2015 at 3:32:56 AM UTC+10, Yichao Yu wrote: > > On Fri, Oct 9, 2015 at 1:24 PM, Gnimuc Key <[email protected] > <javascript:>> wrote: > > so there are no difference between Array{DataType, 1} and > Array{Type{Int64}, > > 1} just as the example showed? what about `foo(x::Array{DataType,1}) > = > x` > > and `foo(x::Array{Type{Int64}, 1})`? > > I think this is a bug in codegen. The intrinsic itself looks fine > > julia> Base.arrayset(Vector{Type{Int}}(2), Float32, 1) > ERROR: TypeError: arrayset: expected Type{Int64}, got Type{Float32} > > > > > > 在 2015年10月10日星期六 UTC+8上午1:17:25,Cedric St-Jean写道: > >> > >> Array{Int64, 1} is an array of Ints. Type{Int64} is the type of a type, > so > >> Array{Type{Int64}} is an array of types. > >> > >> On Friday, October 9, 2015 at 1:11:25 PM UTC-4, Gnimuc Key wrote: > >>> > >>> i think `Array{Type{Int64},1}` is a vector whose element type is > >>> constrained to `Int64`, but i'm confused by the outputs of the code > below: > >>> > >>> > >>> julia> a = Array{Type{Int64}}(2) > >>> 2-element Array{Type{Int64},1}: > >>> #undef > >>> #undef > >>> > >>> julia> a[:] = [Int64, Float32] > >>> 2-element Array{DataType,1}: > >>> Int64 > >>> Float32 > >>> > >>> julia> isa(a[2], eltype(a)) > >>> false > >>> > >>> > >>> julia> a > >>> 2-element Array{Type{Int64},1}: > >>> Int64 > >>> Float32 > >>> > >>> > >>> the last line is so wired. >
