Larry Wall wrote:

On Mon, Dec 06, 2004 at 11:52:22AM -0700, Dan Brian wrote:
: >If I went with "get", the opposite would be "unget" for both historical
: >and huffmaniacal reasons.


Why? (I get the huffman, not the history.) Is it just a nod to unshift?

Given the existence of a unary = for abbreviated use, I'd probably
stick with shift/unshift. (Presumably changing the semantics of
shift from p5 to be list/scalar/n-ary context sensitive, so you'd
have to write "scalar shift" to get Perl 5's shift semantics
in list context.)


What about add/remove?

sub unshift(@a, [EMAIL PROTECTED])
{
 @a.add(@items);
}

We could add :head and :tail, with :head the default, and let push|pop be equivalent to (add|remove).assuming(tail => 1)

As a side note, other than historical consistency, is there a good reason for push/pop to use the end of the array? I'd argue that for a stack, you only want to "know" one address: @stack[0] -- the 'top' of the stack -- and if you ever iterate a stack you're inclined to see the items in "distance-from-top" order, making 0..Inf the right array sequence. If we're going to reorg the function space, let's huffmanize the stack stuff (push/pop/0) and let the other stuff go hang.

=Austin



Reply via email to