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

Re: Semantics of vector operations

Thread Previous | Thread Next
From:
Joe Gottman
Date:
January 22, 2004 17:06
Subject:
Re: Semantics of vector operations
Message ID:
001a01c3e14d$60d04860$e58f8445@carolina.rr.com

----- Original Message ----- 
From: "Luke Palmer" <fibonaci@babylonia.flatirons.org>
To: "Austin Hastings" <Austin_Hastings@Yahoo.com>
Cc: "Larry Wall" <larry@wall.org>; "Language List" <perl6-language@perl.org>
Sent: Thursday, January 22, 2004 4:28 PM
Subject: [perl] Re: Semantics of vector operations


> Austin Hastings writes:
> > How do you handle operator precedence/associativity?
> >
> > That is,
> >
> >    $a + $b + $c
> >
> > If you're going to vectorize, and combine, then you'll want to group. I
> > think making the vectorizer a grouper as well kills two birds with one
> > stone.
> >
> >   $a + >>$b + $c<<
> >
> > vs.
> >
> >   $a +<< ($b + $c)
>
> I have to agree with Larry here, the latter is much cleaner.
>
> I'm actually starting to like this proposal.  I used to shiver at the
> implementation of the old way, where people used the operator to group
> arbitrary parts of the expression.  I wouldn't even know how to parse
> that, much less interpret it when it's parsed.
>
> Now, we have a clear way to call a method on a list of values:
>
>     @list ».method
>
> And a clear way to call a list of methods on a value:
>
>     $value.« @methods
>
> It's turning out pretty nice.

   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.

Joe Gottman



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