develooper Front page | perl.perl6.language | Postings from January 2004

Re: Semantics of vector operations

Thread Previous | Thread Next
From:
Larry Wall
Date:
January 22, 2004 17:21
Subject:
Re: Semantics of vector operations
Message ID:
20040123012000.GC16181@wall.org
On Thu, Jan 22, 2004 at 08:08:13PM -0500, Joe Gottman wrote:
:    I just realized a potential flaw here.  Consider the code
:         $a >>= 1;
: 
:    Will this right-shift the value of $a one bit and assign the result to $a
: (the current meaning)?  Or will it assign the value 1 to each element in the
: array referenced by $a (as suggested by the new syntax).  Both of these are
: perfectly valid operations, and I don't think its acceptable to have the
: same syntax mean both.  I'm aware that using "ยป=" instead of ">>=" will
: eliminate the inconsistency, but not everyone has easy access to Unicode
: keyboards.

Well,

    $a >>=<< 1

would still presumably be unambiguous, and do the right thing, albeit
with run-time dwimmery.  On the other hand, we've renamed all the
other bitwise operators, so maybe we should rename these too:

    +<		bitwise left shift
    +>		bitwise right shift

which also gives us useful string bitshift ops:

    ~<		stringwise left shift
    ~>		stringwise right shift

as well as the never-before-thought-of:

    ?<		boolean left shift
    ?>		boolean right shift

Those last would be a great addition insofar as they could always
participate in constant folding.  Er, unless the right argument is 0,
of course...  :-)

Ain't orthogonality wonderful...

Larry

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About