Martin DeMello wrote:
> There is really no reason to stop
> With defining a 'push' and a 'pop'
> But a function called 'peek'
> Isn't all that unique
> I would much rather see it called 'top'

Nice one. :-)

> And a plausible use of 'peek' paired with 'shift' rather than 'pop'
> would be looking at the first argument to a function without shifting
> that argument out.

Looking at the first you say? Wouldn't that like, ehm, naturally imply
'first' rather than 'peek'? 

I see your point, though. I'd like to see highly cohesive subsets of
methods inside Array for the various uses, such as stack and queue, such
as I take it you propose, instead of the power-reducing suggestions of
having specific Stack/Queue classes which also have been mentioned on
the list. The aliases should then communicate the intended usage of the
programmer. With array now, 'push' and 'pop' communicate "I'm using it
like a stack", but when I suddenly use 'last' it is hard to tell wheter
I'm using it like a stack or doing some magic trick because I know it is
implemented like an array.

I am vary of putting too much emphasis on geometric directions. They
won't be of much use when we're all of in spacestations, weightless and
controlling oh-two recyc machines with Ruby. But my propopal of peek
planted between the pair of push and pop, may have more to do with my
abnormal affection for alliteration, alas. :-)


> But don't you put in new cups from the top? Which would make it a queue
> rather than a stack.

Depends on the type. The last one I refilled frequently didn't have an
opening at the top, so you had a stack of cups that was inserted from
the bottom up. I think you could unscrew the transparent part containing
the cups to avoid rubbing every cup against the insanely simple
"dispenser", but it still went like a stack with a "push_many" with the
bottom as the entrypoint :-)

-- 
(\[ Kent Dahl ]/)_    _~_    __[ http://www.stud.ntnu.no/~kentda/ ]___/~
 ))\_student_/((  \__d L b__/  NTNU - graduate engineering - 5. year  )
( \__\_/__/ ) _)Industrial economics and technological management(
 \____/_\____/ (____engineering.discipline_=_Computer::Technology___)