Interesting point, especially if operator:+= can be overloaded.

@a [+=] @b; 

implies iteratively invoking operator:+=, whereas 

@a [+]= @b;

implies assigning the result of iteratively invoking operator:+


It only matters when they're different. :-|

And, of course, if they ARE different then the implication is that
signature-matching may also be involved, such that the version of
operator:+ (or +=) that gets used can change...

Hell, we might as well throw in multiple dispatch.

Any of you OO guys know of a case where 

$a = $a + $b;   # @A [+]= @B; --> @A = @A [+] @B;

and

$a += $b;       # @A [+=] @B;

should be different? (Intuitively, I get the feeling that these cases
exist, especially in the weird cases kind of like the >> and <<
operators that C++ redefined for I/O. But I'm not sure if that's
paranoia causing me to accept lousy design, or what...)

Or should there be an overloadable operator:[op]= that takes arrays or
lists as its normal context? (Kind of like C++ differentiating between
new and new[])

=Austin


--- Luke Palmer <[EMAIL PROTECTED]> wrote:
> > Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
> > Date: Tue, 29 Oct 2002 21:37:32 +0000
> > From: Aaron Crane <[EMAIL PROTECTED]>
> > Content-Disposition: inline
> > X-SMTPD: qpsmtpd/0.12, http://develooper.com/code/qpsmtpd/
> > 
> > Damian Conway writes:
> > > My personal favorite solution is to use square brackets (for
> their dual
> > > array and indexing connotations, and because they highlight the
> operator
> > > so nicely):
> > > 
> > >   $count = @a + @b;
> > >   @sums  = @a [+] @b;
> > 
> > Mmm, yummy.  I do have a question though (and apologies if I've
> merely
> > missed the answer).  We've got two productive operation-formation
> rules: one
> > saying "add a final = to operate-and-assign", and the other saying
> "wrap in
> > [] to vectorise".  But no-one's said which order they apply in. 
> That is,
> > which of these should I type:
> > 
> >   @x [+]= @y;
> >   @x [+=] @y;
> > 
> > Of course, the rule ordering didn't matter with the "add a leading
> ^ to
> > hype" rule.
> 
> Hmm.  Well, they're different:
> 
>       @x [+]= @y;
>       @x = @x [+] @y;
> 
>       @x [+=] @y;
>       for @x | @y -> $x is rw | $y {
>         $x += $y
>       }
> 
> :)  Is there any advantage in differentiating that?  Or would the
> former *always* optimize to the latter?
> 
> Luke
> 
> > I think I prefer the first one, by the way -- it strikes me as more
> > obviously a vector add.
> > 
> > -- 
> > Aaron Crane * GBdirect Ltd.
> > http://training.gbdirect.co.uk/courses/perl/


__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

Reply via email to