Yukihiro Matsumoto <matz / ruby-lang.org> wrote:
> In message "Re: RCR: Stack, Queue alias methods in Array"
>    on 02/11/26, Nikodemus Siivola <tsiivola / cc.hut.fi> writes:
> 
> |On Tue, 26 Nov 2002, Yukihiro Matsumoto wrote:
> |
> |> top      "top" returns last item?  probably confusing.
> |
> |But that confusion is exactly the reason why it is needed: unless a builtin
> |Stack class is introduced: without it there is always a 1-minute head
> |scratching break to remember which end push operates on.
> 
> But still, array is array.  If you see "top" being last without
> knowing arrays can behave as stacks, the confusion is far stronger
> than lacking "top".

Well, it may not be intuitively obvious if you're not thinking in terms
of stacks, but all that that would need would be for the documentation
to say "the top of the array when viewed as a stack, i.e. the element
that 'pop' would return". It's not confusing in the sense that one would
keep forgetting what it meant and having to look it up (and not nearly
as confusing as rassoc, for instance). Again, if you weren't thinking in
terms of stacks, the usual way to visualise an array is horizontally, so
you'd never use 'top'. It just plugs the hole in the stack abstraction
neatly.

martin