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

Re: Semantics of vector operations

Thread Previous | Thread Next
Larry Wall
January 22, 2004 17:21
Re: Semantics of vector operations
Message ID:
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.


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


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About