[julia-users] Re: Function push! adds objects where it should not

2015-10-13 Thread Dan
perhaps, fill!(instance.ol, Tuple{Int64, Array{Float64}}[]) uses the same address to fill every entry in `instance.ol` and the behavior observed follows. maybe, onstance.ol = [Tuple{Int64,Array{Float64}}[] for i=1:length(instance.ol)] would be better. On Tuesday, October 13, 2015 at 7:52

[julia-users] Re: Function push! adds objects where it should not

2015-10-13 Thread Kristoffer Carlsson
Function arguments are evaluated once. Rewrite fill!(instance.ol, Tuple{Int64, Array{Float64}}[]) to x = Tuple{Int64, Array{Float64}}[] fill!(instance.ol, x) and you see that you are filling the instance with the exact same object. On Tuesday, October 13, 2015 at 6:52:15 PM UTC+2, ami...@gm

[julia-users] Re: Function push! adds objects where it should not

2015-10-13 Thread amiksvi
Thank you to both of you, this makes sense. However I'm a bit surprised that this code was working in 0.3.11, I'm certain of that, so the fill! function was using different objects each time? I'd have thought that such an important thing as evaluation of function arguments would not change from

[julia-users] Re: Function push! adds objects where it should not

2015-10-14 Thread Josh Langsfeld
There must have been some other subtle change you made when converting to 0.4. I see the same fill! behavior in 0.3. julia> VERSION v"0.3.11" julia> X = Array(Vector{Int},5); fill!(X, Int[]); julia> push!(X[1], 11); @show X; X => [[11],[11],[11],[11],[11]] On Tuesday, October 13, 2015 at 6:05

[julia-users] Re: Function push! adds objects where it should not

2015-10-14 Thread Tomas Lycken
I’m a bit surprised that this code was working in 0.3.11 There’s actually no way that code worked exactly as is under 0.3.11, since the Tuple{...} syntax and the AbstractString type, to name a couple of things, weren’t introduced until 0.4. So you probably changed something else too, when you