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.
: 
: But "get" has too strong a class accessor connotation in most OO.
: 
: "unpull?" ;-)

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.)

Though it's awfully tempting to fill in the holes in the periodic table:

    ($a, $b, $c) = @foo *<< 3;

And then just say all the corresponding unaries default to 1 (or the arity
of the left):

    $bit = +<< $number;         # $number +<< 1
    $graph = ~<< $string;       # chip()/chimp()
    $whether = ?<< $boolean;    # presumably clears $boolean
    $elem = *<< $iterator;      # shift $iterator

That would mean that we couldn't use those unaries in front of <<...>> though.

I suppose unary *>> would mean pop.  Blurch.  Let's stick with the binaries,
if we add 'em at all.  I do think

    foo( @bar *<< 3 )
    foo( @bar *>> 3 )

might actually be clearer than

    foo( splice(@bar,0,3) )
    foo( splice(@bar,-3,3) )

Also, note that neither of the latter examples means the same as

    foo( pop(@bar,3) )

since pop would presumably pop them in reverse order from splice.

We also get all the rotates if we allow *<<< and *>>>.

On the other hand, if anyone suggests a list xor:

    @foo *^ @bar

I'll ask whether they mean

    @foo »+^« @bar
    @foo »~^« @bar
    @foo »?^« @bar
    @foo »*^« @bar

Larry

Reply via email to