> # WAT: A warning about using collect()? > > julia> a = [1:3] > WARNING: [a] concatenation is deprecated; use collect(a) instead > in depwarn at deprecated.jl:73 > in oldstyle_vcat_warning at > /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib > in vect at abstractarray.jl:32 > while loading no file, in expression starting on line 0 > 3-element Array{Int64,1}: > 1 > 2 > 3
Julia used to have matlab-like behavior here but is transitioning to making [1:3] == UnitRange{Int}[1:3] Thus currently the deprecation warning and in Julia 0.5 the new behavior will be used. > # WAT: why would a semicolon make the error go away? > > julia> a = [1:3;] > 3-element Array{Int64,1}: > 1 > 2 > 3 This is another way to do collect but not the preferred one (I forget the details). > # This makes sense, I _should_ get a warning every time... > > julia> a = [1:3] > WARNING: [a] concatenation is deprecated; use collect(a) instead > in depwarn at deprecated.jl:73 > in oldstyle_vcat_warning at > /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib > in vect at abstractarray.jl:32 > while loading no file, in expression starting on line 0 > 3-element Array{Int64,1}: > 1 > 2 > 3 > > # WAT: Third time's a charm? We have apparently beaten the interpreter into > submission :-) This is a bug: deprecation warning should only show once but often show several times. > julia> a = [1:3] > 3-element Array{Int64,1}: > 1 > 2 > 3 > > # By way of comparison, I recently ran some old code and discovered that {} > is no longer OK: > > julia> {} > > WARNING: deprecated syntax "{}". > Use "[]" instead. > 0-element Array{Any,1} > > julia> {} > > WARNING: deprecated syntax "{}". > Use "[]" instead. > 0-element Array{Any,1} > > # And apparently in this case, the interpreter will insist _forever_ ... > > julia> {} > > WARNING: deprecated syntax "{}". > Use "[]" instead. > 0-element Array{Any,1} Again, the deprecation-warning bug.