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

Re: Semantics of vector operations

Thread Previous | Thread Next
From:
Luke Palmer
Date:
January 22, 2004 18:04
Subject:
Re: Semantics of vector operations
Message ID:
20040123020326.GA29950@babylonia.flatirons.org
Larry Wall writes:
> 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

I could have sworn we already did that.  I thought they were:

    +<<
    +>>

But I guess that's an extra unneeded character.

Luke

> which àlso 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