2007/10/23, Randy Kramer <rhkramer / gmail.com>:
> On Tuesday 23 October 2007 12:46 am, Konrad Meyer wrote:
> > Push and pop have been around as instructions since the days of asm. The
> > common "visualisation" is to imagine a dinner-plate-stack-holder at a
> buffet.
> > You push plates down into the spring-loaded stack to add more. When you want
> > to remove a plate, you pop it out of the top of the stack. That's probably
> > not the best description of the idea, but you can always google for
> push/pop.
>
> I always liked that visualization.  The problem for me (and I'm not the OP) is
> that in Ruby you have to lift all the plates off, put the new plate on the
> bottom, and then put all the plates back.  (Likewise when you want to "pop"
> that plate.)  ;-)  (Because Ruby uses push and pop on the end of the array
> instead of the beginning.)

I'm not sure what exactly you mean.  #push and #pop just work as one
would expect from a LIFO.

> It's not a major problem, but it did surprise me the first time I ran into it,
> and I suppose this approach is a little easier to implement.
>
> (And, if push and pop were built on a separate "stack" data structure (instead
> of being built on the array structure (with various other paradigms, like
> being able to access any item in the array via the index), this point would
> not come up.)

Frankly, I don't understand your point.  You can use an Array as LIFO
just the same.  There is no additional lifting etc. involved.  And for
this it's completely irrelevant whether they use lowest or highest
index for their operation.

Kind regards

robert