Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-13 Thread Tamas Papp
No need, you were not rude in any way. On Tue, Sep 13 2016, Michele Zaffalon wrote: > Apologies, I did not want to insult or be rude. Thank you again for the > clear explanation. > > On Tue, Sep 13, 2016 at 8:38 AM, Tamas Papp wrote: > >> Please don't put words in my mouth, I

Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-13 Thread Michele Zaffalon
Apologies, I did not want to insult or be rude. Thank you again for the clear explanation. On Tue, Sep 13, 2016 at 8:38 AM, Tamas Papp wrote: > Please don't put words in my mouth, I did not say that. In general, I > find "use case" an elusive concept. I prefer simple building

Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-13 Thread Tamas Papp
Please don't put words in my mouth, I did not say that. In general, I find "use case" an elusive concept. I prefer simple building blocks with clear semantics that I can combine easily to solve problems. Also, whether something "makes sense" is also somewhat subjective and depends on your

Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-13 Thread Michele Zaffalon
Thank you for your explanation. In practice you are saying that consistency has led to this consequence even though there is no use case, and therefore it makes little sense? I am not trying to provoke, it is that I find it easier to internalize the concept, once I know the reason behind that

Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-12 Thread Tamas Papp
Fill behaves this way not because of a specific design choice based on a compelling use case, but because of consistency with other language features. fill does not copy, and arrays are passed by reference in Julia, consequently you have the behavior described below. IMO it is best to learn about

Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-12 Thread Michele Zaffalon
I have been bitten by this myself. Is there a user case for having an array filled with references to the same object? Why would one want this behaviour? On Tue, Sep 13, 2016 at 4:45 AM, Yichao Yu wrote: > > > On Mon, Sep 12, 2016 at 10:33 PM, Zhilong Liu

Re: [julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-12 Thread Yichao Yu
On Mon, Sep 12, 2016 at 10:33 PM, Zhilong Liu wrote: > Hello all, > > I am pretty new to Julia, and I am trying to perform push and pop inside > an array of 1D array elements. For example, I created the following array > with 1000 empty arrays. > > julia> vring = fill([],

[julia-users] Strange behavior of push! and pop! for an array of array elements

2016-09-12 Thread Zhilong Liu
Hello all, I am pretty new to Julia, and I am trying to perform push and pop inside an array of 1D array elements. For example, I created the following array with 1000 empty arrays. julia> vring = fill([], 1000) Then, when I push an element to vring[2], julia> push!(vring[2],1) I got