# Pop/push, shift/unshift

**URL:** <https://rubytalk.org/t/pop-push-shift-unshift/41590>\
**Category:** ruby-talk\
**Created:** [23 October 2007 03:53 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590 "2007-10-23T03:53:02Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Todd\_Benson](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Todd\_Benson](https://rubytalk.org/u/Todd_Benson)\
**Post date:** [24 October 2007 13:54 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/41 "2007-10-24T13:54:34Z")

</div>

Bob, I can only guess that the grief you are talking about has  
something to do with memory management, but I don't see it.

Can someone explain -- with the code above -- why tmp does in fact  
\_not\_ take on NilClass? I think it would be good info for newbies.

Todd

> **···**
>
> On 10/24/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> 
> > On 24-Oct-07, at 9:03 AM, Todd Benson wrote:
> > 
> > \> def dequeue  
> > \> @list.shift  
> > \> end
> > 
> > Save yourself some grief, do it this way:
> > 
> > def dequeue  
> > &nbsp;&nbsp;&nbsp;tmp = @list[0]  
> > &nbsp;&nbsp;&nbsp;@list[0] = nil  
> > &nbsp;&nbsp;&nbsp;@list.shift  
> > &nbsp;&nbsp;&nbsp;tmp  
> > end
> > 
> > Cheers,  
> > Bob

---

<div class="post-metadata">

**Author:** ![Todd\_Benson](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Todd\_Benson](https://rubytalk.org/u/Todd_Benson)\
**Post date:** [24 October 2007 15:21 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/42 "2007-10-24T15:21:47Z")

</div>

Okay, I guess I can answer my own question. Binding is resolved when  
an operator like '=' is interpreted, especially with immutable objects  
(like Fixnum).

a = 1,2,3  
puts a[0].\_\_id\_\_  
#output =\> 3  
b = a  
puts b.\_\_id\_\_  
#output =\> 3  
a[0] = 7  
puts a[0].\_\_id\_\_  
#output =\> 15  
puts b.\_\_id\_\_  
#output =\> 3

For the newbies out there, keep this in mind. The name b put on  
a[0]'s shoes and kept them on. Somebody correct me if I'm wrong.

Todd

> **···**
>
> On 10/24/07, Todd Benson \<caduceass@gmail.com\> wrote:
> 
> > On 10/24/07, Bob Hutchison \<hutch@recursive.ca\> wrote:  
> > \>  
> > \> On 24-Oct-07, at 9:03 AM, Todd Benson wrote:  
> > \>  
> > \> \> def dequeue  
> > \> \> @list.shift  
> > \> \> end  
> > \>  
> > \> Save yourself some grief, do it this way:  
> > \>  
> > \> def dequeue  
> > \> tmp = @list[0]  
> > \> @list[0] = nil  
> > \> @list.shift  
> > \> tmp  
> > \> end  
> > \>  
> > \> Cheers,  
> > \> Bob
> > 
> > Bob, I can only guess that the grief you are talking about has  
> > something to do with memory management, but I don't see it.
> > 
> > Can someone explain -- with the code above -- why tmp does in fact  
> > \_not\_ take on NilClass? I think it would be good info for newbies.
> > 
> > Todd

---

<div class="post-metadata">

**Author:** ![Bob\_Hutchison1](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Bob\_Hutchison1](https://rubytalk.org/u/Bob_Hutchison1)\
**Post date:** [24 October 2007 15:39 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/43 "2007-10-24T15:39:13Z")

</div>

> > > &nbsp;&nbsp;def dequeue  
> > > &nbsp;&nbsp;&nbsp;&nbsp;@list.shift  
> > > &nbsp;&nbsp;end
> > 
> > Save yourself some grief, do it this way:
> > 
> > def dequeue  
> > &nbsp;&nbsp;&nbsp;tmp = @list[0]  
> > &nbsp;&nbsp;&nbsp;@list[0] = nil  
> > &nbsp;&nbsp;&nbsp;@list.shift  
> > &nbsp;&nbsp;&nbsp;tmp  
> > end
> > 
> > Cheers,  
> > Bob
> 
> Bob, I can only guess that the grief you are talking about has  
> something to do with memory management, but I don't see it.

It has to do with an optimisation in the implementation of shift (there's a series of posts regarding this earlier in this thread). In brief, shift optimises itself by 'shifting' the start of the array rather than shifting the contents of the array. The effect is that using shift leaves an old part of the array in front of the start of the array (but you cannot access it). The problem is that the shift implementation doesn't 'clear' the original 0th element, so it is still in memory, is not accessible, but the garbage collector can see it. In effect, the object referenced isn't collected because there is a reference. This is a memory leak. Sooner or later it'll get fixed up, but sometimes it really is later.

> Can someone explain -- with the code above -- why tmp does in fact  
> \_not\_ take on NilClass? I think it would be good info for newbies.

In the above code, the shift method, through an involved but hidden technique implemented by Ruby, arranges for the 0th element of the list to 'disappear', for the original @list[1] to become @list[0] and so on, for the array size to be reduced by one, and returns the original @list[0].

So, tmp 'remembers' the original @list[0]. The '@list[0] = nil' removes the reference to what is now in tmp, and @list.shift makes the original @list[0] 'disappear', and the last reference to tmp returns it as the result of the method.

Unfortunately it isn't as simple as everyone would like it to be. But, as I've mentioned elsewhere, this will all go away in some future version of Ruby. Already Ruby 1.8.5 is much better than 1.8.4

Cheers,  
Bob

> **···**
>
> On 24-Oct-07, at 9:54 AM, Todd Benson wrote:
> 
> > On 10/24/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> > 
> > > On 24-Oct-07, at 9:03 AM, Todd Benson wrote:
> 
> > Todd
> 
> ----  
> Bob Hutchison -- tumblelog at [http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
> Recursive Design Inc. -- weblog at [http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
> [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [24 October 2007 19:02 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/44 "2007-10-24T19:02:12Z")

</div>

\<snip

> \>  
> \> Can someone explain -- with the code above -- why tmp does in fact  
> \> \_not\_ take on NilClass? I think it would be good info for newbies.  
> \>
> 
> In the above code, the shift method, through an involved but hidden  
> technique implemented by Ruby, arranges for the 0th element of the  
> list to 'disappear', for the original @list[1] to become @list[0] and  
> so on, for the array size to be reduced by one, and returns the  
> original @list[0].
> 
> So, tmp 'remembers' the original @list[0]. The '@list[0] = nil'  
> removes the reference to what is now in tmp,

I believe that this is not true, imagine the GC freeing all objects  
that are nil!  
Seems very strange to me.

R.

> **···**
>
> On 10/24/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> 
> --  
> what do I think about Ruby?  
> [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

---

<div class="post-metadata">

**Author:** ![David\_A\_Black1](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@David\_A\_Black1](https://rubytalk.org/u/David_A_Black1)\
**Post date:** [24 October 2007 19:16 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/45 "2007-10-24T19:16:56Z")

</div>

Hi --

> > > > &nbsp;&nbsp;def dequeue  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;@list.shift  
> > > > &nbsp;&nbsp;end
> > > 
> > > Save yourself some grief, do it this way:
> > > 
> > > def dequeue  
> > > &nbsp;&nbsp;&nbsp;tmp = @list[0]  
> > > &nbsp;&nbsp;&nbsp;@list[0] = nil  
> > > &nbsp;&nbsp;&nbsp;@list.shift  
> > > &nbsp;&nbsp;&nbsp;tmp  
> > > end
> > > 
> > > Cheers,  
> > > Bob
> > 
> > Bob, I can only guess that the grief you are talking about has  
> > something to do with memory management, but I don't see it.
> > 
> > Can someone explain -- with the code above -- why tmp does in fact  
> > \_not\_ take on NilClass? I think it would be good info for newbies.
> > 
> > Todd
> 
> Okay, I guess I can answer my own question. Binding is resolved when  
> an operator like '=' is interpreted, especially with immutable objects  
> (like Fixnum).
> 
> a = 1,2,3  
> puts a[0].\_\_id\_\_  
> #output =\> 3  
> b = a  
> puts b.\_\_id\_\_  
> #output =\> 3  
> a[0] = 7  
> puts a[0].\_\_id\_\_  
> #output =\> 15  
> puts b.\_\_id\_\_  
> #output =\> 3
> 
> For the newbies out there, keep this in mind. The name b put on  
> a[0]'s shoes and kept them on. Somebody correct me if I'm wrong.

I'm not seeing what you're seeing:

irb(main):014:0\> a = 1,2,3  
=\> [1, 2, 3]  
irb(main):015:0\> a[0].\_\_id\_\_  
=\> 3  
irb(main):016:0\> b = a  
=\> [1, 2, 3]  
irb(main):017:0\> b.\_\_id\_\_  
=\> 1669980 # Are you really seeing 3 here?  
irb(main):018:0\> a[0] = 7  
=\> 7  
irb(main):019:0\> a[0].\_\_id\_\_  
=\> 15  
irb(main):020:0\> b.\_\_id\_\_  
=\> 1669980 # And here?

When you do b = a, you're binding b to the same object as a. I don't  
know why b would think you had bound it to a[0].

David

> **···**
>
> On Thu, 25 Oct 2007, Todd Benson wrote:
> 
> > On 10/24/07, Todd Benson \<caduceass@gmail.com\> wrote:
> > 
> > > On 10/24/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> > > 
> > > > On 24-Oct-07, at 9:03 AM, Todd Benson wrote:
> 
> --  
> Upcoming training by David A. Black/Ruby Power and Light, LLC:  
> &nbsp;&nbsp;&nbsp;\* Advancing With Rails, Edison, NJ, November 6-9  
> &nbsp;&nbsp;&nbsp;\* Advancing With Rails, Berlin, Germany, November 19-22  
> &nbsp;&nbsp;&nbsp;\* Intro to Rails, London, UK, December 3-6 (by Skills Matter)  
> See [http://www.rubypal.com](http://www.rubypal.com) for details!

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [24 October 2007 19:09 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/46 "2007-10-24T19:09:21Z")

</div>

Sorry for replying to my own post, can somebody confirm please that  
the following code proves that Array#shift does not leak?  
Thx in advance  
def count  
&nbsp;&nbsp;i = 0  
&nbsp;&nbsp;ObjectSpace.each\_object{ i += 1 }  
&nbsp;&nbsp;i  
end

a = []  
10.times do  
&nbsp;&nbsp;10\_000.times do  
&nbsp;&nbsp;&nbsp;&nbsp;a \<\< "a"  
&nbsp;&nbsp;&nbsp;&nbsp;a.shift  
&nbsp;&nbsp;end  
&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;p count  
end  
381  
382  
382  
382  
382  
382  
382  
382  
382  
382

Robert

---

<div class="post-metadata">

**Author:** ![Todd\_Benson](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Todd\_Benson](https://rubytalk.org/u/Todd_Benson)\
**Post date:** [24 October 2007 20:17 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/47 "2007-10-24T20:17:08Z")

</div>

You're right David. That was supposed to be b = a[0] and \_not\_ b = a.

Todd

> **···**
>
> On 10/24/07, David A. Black \<dblack@rubypal.com\> wrote:
> 
> > Hi --
> > 
> > On Thu, 25 Oct 2007, Todd Benson wrote:
> > 
> > \> On 10/24/07, Todd Benson \<caduceass@gmail.com\> wrote:  
> > \> Okay, I guess I can answer my own question. Binding is resolved when  
> > \> an operator like '=' is interpreted, especially with immutable objects  
> > \> (like Fixnum).  
> > \>  
> > \> a = 1,2,3  
> > \> puts a[0].\_\_id\_\_  
> > \> #output =\> 3  
> > \> b = a  
> > \> puts b.\_\_id\_\_  
> > \> #output =\> 3  
> > \> a[0] = 7  
> > \> puts a[0].\_\_id\_\_  
> > \> #output =\> 15  
> > \> puts b.\_\_id\_\_  
> > \> #output =\> 3  
> > \>  
> > \> For the newbies out there, keep this in mind. The name b put on  
> > \> a[0]'s shoes and kept them on. Somebody correct me if I'm wrong.
> > 
> > I'm not seeing what you're seeing:
> > 
> > irb(main):014:0\> a = 1,2,3  
> > =\> [1, 2, 3]  
> > irb(main):015:0\> a[0].\_\_id\_\_  
> > =\> 3  
> > irb(main):016:0\> b = a  
> > =\> [1, 2, 3]  
> > irb(main):017:0\> b.\_\_id\_\_  
> > =\> 1669980 # Are you really seeing 3 here?  
> > irb(main):018:0\> a[0] = 7  
> > =\> 7  
> > irb(main):019:0\> a[0].\_\_id\_\_  
> > =\> 15  
> > irb(main):020:0\> b.\_\_id\_\_  
> > =\> 1669980 # And here?
> > 
> > When you do b = a, you're binding b to the same object as a. I don't  
> > know why b would think you had bound it to a[0].
> > 
> > David

---

<div class="post-metadata">

**Author:** ![Bob\_Hutchison1](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Bob\_Hutchison1](https://rubytalk.org/u/Bob_Hutchison1)\
**Post date:** [24 October 2007 20:34 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/48 "2007-10-24T20:34:55Z")

</div>

Hi,

> Sorry for replying to my own post, can somebody confirm please that  
> the following code proves that Array#shift does not leak?  
> Thx in advance  
> def count  
> &nbsp;&nbsp;i = 0  
> &nbsp;&nbsp;ObjectSpace.each\_object{ i += 1 }  
> &nbsp;&nbsp;i  
> end
> 
> a =   
> 10.times do  
> &nbsp;&nbsp;10\_000.times do  
> &nbsp;&nbsp;&nbsp;&nbsp;a \<\< "a"  
> &nbsp;&nbsp;&nbsp;&nbsp;a.shift  
> &nbsp;&nbsp;end  
> &nbsp;&nbsp;ObjectSpace.garbage\_collect  
> &nbsp;&nbsp;p count  
> end  
> 381  
> 382
> 
> Robert

Try it this way:

class Thing  
end

def count  
&nbsp;&nbsp;&nbsp;i = 0  
&nbsp;&nbsp;&nbsp;ObjectSpace.each\_object(Thing){ i += 1 }  
&nbsp;&nbsp;&nbsp;i  
end

a =   
10.times do  
&nbsp;&nbsp;&nbsp;10\_000.times do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a \<\< Thing.new  
&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;&nbsp;10\_000.times do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.shift  
&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;&nbsp;puts "count(1): #{count} size: #{a.size}"  
&nbsp;&nbsp;&nbsp;a.push(nil).pop  
&nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;&nbsp;puts "count(2): #{count} size: #{a.size}"

&nbsp;&nbsp;&nbsp;10\_000.times do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a \<\< Thing.new  
&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;&nbsp;10\_000.times do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a[0] = nil # \<\<\<\<\<\< !!!!  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.shift  
&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;&nbsp;puts "count(3): #{count} size: #{a.size}"  
end

count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0  
count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0  
count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0  
count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0  
count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0  
count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0  
count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0  
count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0  
count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0  
count(1): 10000 size: 0  
count(2): 0 size: 0  
count(3): 0 size: 0

> **···**
>
> On 24-Oct-07, at 3:09 PM, Robert Dober wrote:
> 
> ----  
> Bob Hutchison -- tumblelog at [http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
> Recursive Design Inc. -- weblog at [http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
> [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [24 October 2007 21:03 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/49 "2007-10-24T21:03:08Z")

</div>

Amazing Bob,  
it has nothing to do with nil though, but with the assignment to a[0]  
change a[0] = nil to a[0]=42, you get the same results.  
You can even do the following

def count  
&nbsp;&nbsp;i = 0  
&nbsp;&nbsp;ObjectSpace.each\_object{ i += 1 }  
&nbsp;&nbsp;i  
end

a =   
&nbsp;&nbsp;10\_000.times do  
&nbsp;&nbsp;&nbsp;&nbsp;a \<\< Object.new  
&nbsp;&nbsp;end  
&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;10\_000.times do  
&nbsp;&nbsp;&nbsp;&nbsp;a.shift  
&nbsp;&nbsp;end  
&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;puts "count(1): #{count} size: #{a.size}"  
&nbsp;&nbsp;a.push(nil).pop  
&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;puts "count(2): #{count} size: #{a.size}"

&nbsp;&nbsp;10\_000.times do  
&nbsp;&nbsp;&nbsp;&nbsp;a \<\< Object.new  
&nbsp;&nbsp;end  
&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;10\_000.times do  
&nbsp;&nbsp;a[0] = Object.new  
&nbsp;&nbsp;&nbsp;&nbsp;a.shift  
&nbsp;&nbsp;end  
&nbsp;&nbsp;ObjectSpace.garbage\_collect  
&nbsp;&nbsp;puts "count(3): #{count} size: #{a.size}"

count(1): 10386 size: 0  
count(2): 389 size: 0  
count(3): 392 size: 0

There remains one thing to be clarified, is this really a bug?  
I do not think so, I just ran this until I got 200 points on my terminal :-0

a =   
loop do  
a \<\< Array.new( 1\_000\_000){ Object.new }  
a.shift  
$stdout.print "."  
$stdout.flush  
end

on my Zenwalk box memory is allocated and released regualrely, I doubt  
if ObjectSpace is the right tool to use.

Anyway forgive me to be blunt but everybody should just use Array#shift.

Cheers  
Robert

> **···**
>
> On 10/24/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> 
> > Hi,
> > 
> > On 24-Oct-07, at 3:09 PM, Robert Dober wrote:
> > 
> > \> Sorry for replying to my own post, can somebody confirm please that  
> > \> the following code proves that Array#shift does not leak?  
> > \> Thx in advance  
> > \> def count  
> > \> i = 0  
> > \> ObjectSpace.each\_object{ i += 1 }  
> > \> i  
> > \> end  
> > \>  
> > \> a =   
> > \> 10.times do  
> > \> 10\_000.times do  
> > \> a \<\< "a"  
> > \> a.shift  
> > \> end  
> > \> ObjectSpace.garbage\_collect  
> > \> p count  
> > \> end  
> > \> 381  
> > \> 382  
> > \> 382  
> > \> 382  
> > \> 382  
> > \> 382  
> > \> 382  
> > \> 382  
> > \> 382  
> > \> 382  
> > \>  
> > \> Robert  
> > \>
> > 
> > Try it this way:
> > 
> > class Thing  
> > end
> > 
> > def count  
> > &nbsp;&nbsp;&nbsp;i = 0  
> > &nbsp;&nbsp;&nbsp;ObjectSpace.each\_object(Thing){ i += 1 }  
> > &nbsp;&nbsp;&nbsp;i  
> > end
> > 
> > a =   
> > 10.times do  
> > &nbsp;&nbsp;&nbsp;10\_000.times do  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a \<\< Thing.new  
> > &nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
> > &nbsp;&nbsp;&nbsp;10\_000.times do  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.shift  
> > &nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
> > &nbsp;&nbsp;&nbsp;puts "count(1): #{count} size: #{a.size}"  
> > &nbsp;&nbsp;&nbsp;a.push(nil).pop  
> > &nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
> > &nbsp;&nbsp;&nbsp;puts "count(2): #{count} size: #{a.size}"
> > 
> > &nbsp;&nbsp;&nbsp;10\_000.times do  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a \<\< Thing.new  
> > &nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
> > &nbsp;&nbsp;&nbsp;10\_000.times do  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a[0] = nil # \<\<\<\<\<\< !!!!  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.shift  
> > &nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;ObjectSpace.garbage\_collect  
> > &nbsp;&nbsp;&nbsp;puts "count(3): #{count} size: #{a.size}"  
> > end
> > 
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0  
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0  
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0  
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0  
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0  
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0  
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0  
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0  
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0  
> > count(1): 10000 size: 0  
> > count(2): 0 size: 0  
> > count(3): 0 size: 0
> > 
> > ----  
> > Bob Hutchison -- tumblelog at http://  
> > www.recursive.ca/so/  
> > Recursive Design Inc. -- weblog at [http://www.recursive.ca/](http://www.recursive.ca/)  
> > hutch  
> > [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/](http://www.raconteur.info/)  
> > cms-for-static-content/home/

---

<div class="post-metadata">

**Author:** ![Bob\_Hutchison1](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Bob\_Hutchison1](https://rubytalk.org/u/Bob_Hutchison1)\
**Post date:** [24 October 2007 23:23 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/50 "2007-10-24T23:23:14Z")

</div>

The code in Ruby that deals with the stuff before the start of the array is non-trivial. The push(nil).pop thing I did, or the use of \<\< you did triggers a cleanup. If you do your latest example without interleaving the \<\< and shift you'll have a problem (change the implementation of the Thing class in my example to allocate the million element array and see what happens -- well DON'T actually, you won't like what it does to your machine).

The trouble here is that the normal use of queues involves filling them up then emptying them. If you use an Array and Array.shift to empty the queue there's going to be at least one element 'stuck' in front of the array, likely more than 1. This might not matter but it might. It mattered to my cache implementation, and it mattered to Mongrel's task management.

Cheers,  
Bob

> **···**
>
> On 24-Oct-07, at 5:03 PM, Robert Dober wrote:
> 
> > There remains one thing to be clarified, is this really a bug?  
> > I do not think so, I just ran this until I got 200 points on my terminal :-0
> > 
> > a =   
> > loop do  
> > a \<\< Array.new( 1\_000\_000){ Object.new }  
> > a.shift  
> > $stdout.print "."  
> > $stdout.flush  
> > end
> 
> ----  
> Bob Hutchison -- tumblelog at [http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
> Recursive Design Inc. -- weblog at [http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
> [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [25 October 2007 05:12 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/51 "2007-10-25T05:12:54Z")

</div>

> \> There remains one thing to be clarified, is this really a bug?  
> \> I do not think so, I just ran this until I got 200 points on my  
> \> terminal :-0  
> \>  
> \> a =   
> \> loop do  
> \> a \<\< Array.new( 1\_000\_000){ Object.new }  
> \> a.shift  
> \> $stdout.print "."  
> \> $stdout.flush  
> \> end
> 
> The code in Ruby that deals with the stuff before the start of the  
> array is non-trivial. The push(nil).pop thing I did, or the use of \<\<  
> you did triggers a cleanup. If you do your latest example without  
> interleaving the \<\< and shift you'll have a problem (change the  
> implementation of the Thing class in my example to allocate the  
> million element array and see what happens -- well DON'T actually,  
> you won't like what it does to your machine).
> 
> The trouble here is that the normal use of queues involves filling  
> them up then emptying them. If you use an Array and Array.shift to  
> empty the queue there's going to be at least one element 'stuck' in  
> front of the array, likely more than 1. This might not matter but it  
> might. It mattered to my cache implementation, and it mattered to  
> Mongrel's task management.

Well I guess I have to believe you, but I would \*love\* to reproduce it  
if I do  
times do  
&nbsp;&nbsp;&nbsp;\<\<  
end  
times do  
&nbsp;&nbsp;shift  
end  
it will leak?

R.

> **···**
>
> On 10/24/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> 
> > On 24-Oct-07, at 5:03 PM, Robert Dober wrote:
> > 
> > Cheers,  
> > Bob
> > 
> > ----  
> > Bob Hutchison -- tumblelog at http://  
> > www.recursive.ca/so/  
> > Recursive Design Inc. -- weblog at [http://www.recursive.ca/](http://www.recursive.ca/)  
> > hutch  
> > [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/](http://www.raconteur.info/)  
> > cms-for-static-content/home/
> 
> --  
> what do I think about Ruby?  
> [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

---

<div class="post-metadata">

**Author:** ![Bob\_Hutchison1](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Bob\_Hutchison1](https://rubytalk.org/u/Bob_Hutchison1)\
**Post date:** [25 October 2007 11:04 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/52 "2007-10-25T11:04:19Z")

</div>

Hi,

> Well I guess I have to believe you, but I would \*love\* to reproduce it  
> if I do  
> times do  
> &nbsp;&nbsp;&nbsp;\<\<  
> end  
> times do  
> &nbsp;&nbsp;shift  
> end  
> it will leak?

How else would you describe the 10k Things left in memory after the shifts in the modified version of your test case?

Cheers,  
Bob

> **···**
>
> On 25-Oct-07, at 1:12 AM, Robert Dober wrote:
> 
> > R.
> 
> ----  
> Bob Hutchison -- tumblelog at [http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
> Recursive Design Inc. -- weblog at [http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
> [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [25 October 2007 13:55 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/53 "2007-10-25T13:55:59Z")

</div>

But that is assuming that the ObjectSpace tools tell the truth, it  
does however not look like that on my box.  
I have therefore no reason to believe that the above structure of the  
code will leak, and have asked you if it will.  
I will kill my box tonight 😉 (or not).  
R.

> **···**
>
> On 10/25/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> 
> > Hi,
> > 
> > On 25-Oct-07, at 1:12 AM, Robert Dober wrote:
> > 
> > \> Well I guess I have to believe you, but I would \*love\* to reproduce it  
> > \> if I do  
> > \> times do  
> > \> \<\<  
> > \> end  
> > \> times do  
> > \> shift  
> > \> end  
> > \> it will leak?
> > 
> > How else would you describe the 10k Things left in memory after the  
> > shifts in the modified version of your test case?
> 
> --  
> what do I think about Ruby?  
> [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

---

<div class="post-metadata">

**Author:** ![Eric\_Mahurin](https://avatars.discourse-cdn.com/v4/letter/e/b4bc9f/32.png) [@Eric\_Mahurin](https://rubytalk.org/u/Eric_Mahurin)\
**Post date:** [25 October 2007 16:40 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/54 "2007-10-25T16:40:56Z")

</div>

The problem is that Ruby's COW (copy-on-write) scheme is messed up for  
arrays. I've found much worse cases performance and memory-wise. Try  
doing a small #slice on a big array a bunch and modify the small  
slices. I made a 1.9 patch a couple years ago that fixed the problem  
and made ALL operations near the front just as fast as the operations  
on the back. Unfortunately, it never made it in. The way I did it  
might be unique, not sure. I thought C++ deque does something  
similiar, but it doesn't. When I find time, I'll try to do the fix  
again.

> **···**
>
> On 10/25/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> 
> > Hi,
> > 
> > On 25-Oct-07, at 1:12 AM, Robert Dober wrote:
> > 
> > \> Well I guess I have to believe you, but I would \*love\* to reproduce it  
> > \> if I do  
> > \> times do  
> > \> \<\<  
> > \> end  
> > \> times do  
> > \> shift  
> > \> end  
> > \> it will leak?
> > 
> > How else would you describe the 10k Things left in memory after the  
> > shifts in the modified version of your test case?

---

<div class="post-metadata">

**Author:** ![Bob\_Hutchison1](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Bob\_Hutchison1](https://rubytalk.org/u/Bob_Hutchison1)\
**Post date:** [25 October 2007 16:17 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/55 "2007-10-25T16:17:42Z")

</div>

> > Hi,
> > 
> > > Well I guess I have to believe you, but I would \*love\* to reproduce it  
> > > if I do  
> > > times do  
> > > &nbsp;&nbsp;&nbsp;\<\<  
> > > end  
> > > times do  
> > > &nbsp;&nbsp;shift  
> > > end  
> > > it will leak?
> > 
> > How else would you describe the 10k Things left in memory after the  
> > shifts in the modified version of your test case?
> 
> But that is assuming that the ObjectSpace tools tell the truth, it  
> does however not look like that on my box.  
> I have therefore no reason to believe that the above structure of the  
> code will leak, and have asked you if it will.  
> I will kill my box tonight 😉 (or not).

I guess you'll have to convince your self 🙂

Cheers,  
Bob

> **···**
>
> On 25-Oct-07, at 9:55 AM, Robert Dober wrote:
> 
> > On 10/25/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> > 
> > > On 25-Oct-07, at 1:12 AM, Robert Dober wrote:
> 
> > R.
> > 
> > --  
> > what do I think about Ruby?  
> > [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)
> 
> ----  
> Bob Hutchison -- tumblelog at [http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
> Recursive Design Inc. -- weblog at [http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
> [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

---

<div class="post-metadata">

**Author:** ![Bob\_Hutchison1](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Bob\_Hutchison1](https://rubytalk.org/u/Bob_Hutchison1)\
**Post date:** [25 October 2007 19:45 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/56 "2007-10-25T19:45:41Z")

</div>

Eric, thanks for the information.

Cheers,  
Bob

> **···**
>
> On 25-Oct-07, at 12:40 PM, Eric Mahurin wrote:
> 
> > The problem is that Ruby's COW (copy-on-write) scheme is messed up for  
> > arrays. I've found much worse cases performance and memory-wise. Try  
> > doing a small #slice on a big array a bunch and modify the small  
> > slices. I made a 1.9 patch a couple years ago that fixed the problem  
> > and made ALL operations near the front just as fast as the operations  
> > on the back. Unfortunately, it never made it in. The way I did it  
> > might be unique, not sure. I thought C++ deque does something  
> > similiar, but it doesn't. When I find time, I'll try to do the fix  
> > again.
> 
> ----  
> Bob Hutchison -- tumblelog at [http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
> Recursive Design Inc. -- weblog at [http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
> [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [25 October 2007 17:57 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/57 "2007-10-25T17:57:58Z")

</div>

> \>\> Hi,  
> \>\>  
> \>\>  
> \>\>\> Well I guess I have to believe you, but I would \*love\* to  
> \>\>\> reproduce it  
> \>\>\> if I do  
> \>\>\> times do  
> \>\>\> \<\<  
> \>\>\> end  
> \>\>\> times do  
> \>\>\> shift  
> \>\>\> end  
> \>\>\> it will leak?  
> \>\>  
> \>\> How else would you describe the 10k Things left in memory after the  
> \>\> shifts in the modified version of your test case?  
> \> But that is assuming that the ObjectSpace tools tell the truth, it  
> \> does however not look like that on my box.  
> \> I have therefore no reason to believe that the above structure of the  
> \> code will leak, and have asked you if it will.  
> \> I will kill my box tonight 😉 (or not).
> 
> I guess you'll have to convince your self 🙂

yes I have because it just did not happen,

526/28 \> uname -a && ruby -v  
Linux zenwalk 2.6.18.1 #1 SMP PREEMPT Mon Oct 30 15:32:27 CET 2006  
i686 athlon-4 i386 GNU/Linux  
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]

the program was  
N = 1000  
M = 1000  
a =   
loop do  
&nbsp;&nbsp;N.times do  
&nbsp;&nbsp;&nbsp;&nbsp;a \<\< Array.new( M ){ Object.new }  
&nbsp;&nbsp;end  
&nbsp;&nbsp;N.times do  
&nbsp;&nbsp;&nbsp;&nbsp;a.shift  
&nbsp;&nbsp;end  
end

Ruby allocated up to 43M and then decided to release 3M regularly,  
seems a very reasonable strategy to me.  
I feel that it would be nice to show the exact leaking code so that I  
can run it.

Cheers  
Robert

> **···**
>
> On 10/25/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> 
> > On 25-Oct-07, at 9:55 AM, Robert Dober wrote:  
> > \> On 10/25/07, Bob Hutchison \<hutch@recursive.ca\> wrote:  
> > \>\> On 25-Oct-07, at 1:12 AM, Robert Dober wrote:
> 
> --  
> what do I think about Ruby?  
> [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [25 October 2007 20:41 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/58 "2007-10-25T20:41:54Z")

</div>

Now this is all very great but could you share with us what is going  
on, right now I just see people complaining that it is broken, no  
reference to a bug report, no test code, I feel that this is highly  
unfair to Ruby.

Whatever I am not going to try to reproduce an error that might not  
even be there.  
I have not found any reference to this on Ruby core, could you please  
give a pointer to your patch Eric?

Robert

> **···**
>
> On 10/25/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> 
> > On 25-Oct-07, at 12:40 PM, Eric Mahurin wrote:  
> > \> The problem is that Ruby's COW (copy-on-write) scheme is messed up for  
> > \> arrays. I've found much worse cases performance and memory-wise. Try  
> > \> doing a small #slice on a big array a bunch and modify the small  
> > \> slices. I made a 1.9 patch a couple years ago that fixed the problem  
> > \> and made ALL operations near the front just as fast as the operations  
> > \> on the back. Unfortunately, it never made it in. The way I did it  
> > \> might be unique, not sure. I thought C++ deque does something  
> > \> similiar, but it doesn't. When I find time, I'll try to do the fix  
> > \> again.
> > 
> > Eric, thanks for the information.
> 
> --  
> what do I think about Ruby?  
> [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

---

<div class="post-metadata">

**Author:** ![Bob\_Hutchison1](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Bob\_Hutchison1](https://rubytalk.org/u/Bob_Hutchison1)\
**Post date:** [25 October 2007 20:43 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/59 "2007-10-25T20:43:45Z")

</div>

> > I guess you'll have to convince your self 🙂
> 
> yes I have because it just did not happen,
> 
> 526/28 \> uname -a && ruby -v  
> Linux zenwalk 2.6.18.1 #1 SMP PREEMPT Mon Oct 30 15:32:27 CET 2006  
> i686 athlon-4 i386 GNU/Linux  
> ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
> 
> the program was  
> N = 1000  
> M = 1000  
> a =   
> loop do  
> &nbsp;&nbsp;N.times do  
> &nbsp;&nbsp;&nbsp;&nbsp;a \<\< Array.new( M ){ Object.new }  
> &nbsp;&nbsp;end  
> &nbsp;&nbsp;N.times do  
> &nbsp;&nbsp;&nbsp;&nbsp;a.shift  
> &nbsp;&nbsp;end  
> end
> 
> Ruby allocated up to 43M and then decided to release 3M regularly,  
> seems a very reasonable strategy to me.  
> I feel that it would be nice to show the exact leaking code so that I  
> can run it.

You need to be careful what it is you are testing.

Try the tiny variation I've supplied below as it is, it'll execute relatively benignly. Then comment out the crucial line indicated by the comment. If you dare. BTW, if you run this make sure you keep on top of things and kill it before it starts screwing up your machine. Make sure you don't have anything important unsaved.

Why don't we keep all the 'a' arrays we generate? Shouldn't cause a problem right? If fact if you don't comment out the crucial line memory use will grow relatively slowly. If you do comment it out, then, well, it \*is\* your machine.

BTW, the \*only\* thing special about nil is that there is only one of them. You could use a symbol, true/false, a number -- just don't create a new object.

What happens if you comment out the whole second N.times loop? I get strangely similar behaviour to just commenting out the crucial line. Why's that? Because, in neither case, none of the arrays of Object is being collected.

If you get the behaviour I'm getting, how do you explain it other than as a leak?

Innocent bystanders: if you comment out that crucial line before running the program PAY ATTENTION AND BE READY TO KILL THE PROCESS BEFORE IT LOCKS UP YOUR MACHINE (very bad on OS X, it is an abrupt lockup of the system after about 20s on my machine, Ctrl-C won't work, get either your activity monitor up and visible or the force quit dialog).

N = 1000  
M = 1000

as =   
loop do  
&nbsp;&nbsp;&nbsp;a =   
&nbsp;&nbsp;&nbsp;N.times do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a \<\< Array.new( M ){ Object.new }  
&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;N.times do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a[0] = nil # \<\<\< the crucial line  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a.shift  
&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;as \<\< a

&nbsp;&nbsp;&nbsp;GC.start  
&nbsp;&nbsp;&nbsp;STDERR \<\< '.'  
end

Cheers,  
Bob

> **···**
>
> On 25-Oct-07, at 1:57 PM, Robert Dober wrote:
> 
> > On 10/25/07, Bob Hutchison \<hutch@recursive.ca\> wrote:
> 
> > Cheers  
> > Robert
> > 
> > --  
> > what do I think about Ruby?  
> > [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)
> 
> ----  
> Bob Hutchison -- tumblelog at [http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
> Recursive Design Inc. -- weblog at [http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
> [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

---

<div class="post-metadata">

**Author:** ![Bob\_Hutchison1](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Bob\_Hutchison1](https://rubytalk.org/u/Bob_Hutchison1)\
**Post date:** [25 October 2007 20:46 UTC](https://rubytalk.org/t/pop-push-shift-unshift/41590/60 "2007-10-25T20:46:58Z")

</div>

> Now this is all very great but could you share with us what is going  
> on, right now I just see people complaining that it is broken, no  
> reference to a bug report, no test code, I feel that this is highly  
> unfair to Ruby.
> 
> Whatever I am not going to try to reproduce an error that might not  
> even be there.  
> I have not found any reference to this on Ruby core, could you please  
> give a pointer to your patch Eric?

Robert, I've provided several pieces of code to illustrate this problem.

I'm afraid this thread has the potential to degenerate very very quickly. I'm sorry I'm involved, and I'd very much like to be uninvolved as of now.

Cheers,  
Bob

> **···**
>
> On 25-Oct-07, at 4:41 PM, Robert Dober wrote:
> 
> > Robert
> > 
> > --  
> > what do I think about Ruby?  
> > [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)
> 
> ----  
> Bob Hutchison -- tumblelog at [http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
> Recursive Design Inc. -- weblog at [http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
> [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

[Previous page](https://rubytalk.org/t/pop-push-shift-unshift/41590.md?page=2)

[Next page](https://rubytalk.org/t/pop-push-shift-unshift/41590.md?page=4)
