At 1:56 PM +0100 6/20/02, Peter Haworth wrote: >On Wed, 19 Jun 2002 12:15:57 -0400, Dan Sugalski wrote: >> At 6:08 PM +0200 6/19/02, Stéphane Payrard wrote: >> >Should not we think matrices in the light of hyperators? >> >> Of course. But the hyper version of the operators all map directly to >> vtable entries. @foo = @bar ^+ @baz;, for example, maps the + >> directly onto the add entry in @bar's vtable. That's how the >> hyper-operators are all going to work. > >Are you sure?
Yes. >What about these: Okay, I see the problem. While the hyperoperators map to the 'act on the entirety' vtable entries in general, in some cases it won't. Parrot's got a "Left-hand side wins" rule, so in those cases where it can't, we need to fall back to explicit looping. (And yes, this may mean that many operations may not be commutative, but there's not much for that) >1 @aaa = @a ^+ @aa; # @aaa[$i] = @a[$i] + @aa[$i] >2 $sss = $s + $ss; # $sss = $s + $ss >3 @aaa = @a ^+ $ss; # @aaa[$i] = @a[$i] + $ss >4 @aaa = $s ^+ @aa; # @aaa[$i] = $s + @aa[$i] >5 $sss = @a + @aa; # $sss = @a.length + @aa.length > >1 and 2 are the simple cases. The + vtable methods on scalars and arrays >obviously deal with adds and hyper-adds respectively, when all variables are >the same type. Yup. >3 could be simple, too. Array's add vmethod could replicate a scalar second >argument for each element of its first argument. Something like that, yes. I doubt there'll be real duplication, but it'll seem like that. >4 starts looking interesting. Does scalars add vmethod detect list/array >context and turn hyper? Or do we compile this into the equivalent of @aaa = >@($s) ^+ @aa; creating a temporary array PMC, so it has the correct vmethod? That's the same as "$s + @a" unless Larry declares otherwise, in which case it'll need to get an explicit loop. I think it won't, though. >If 5 is still legal in perl6, does that get compiled as the comment? While there won't be explicit calls to the length method, yes it'll probably get compiled the way that perl 5 does it, unless Larry deems otherwise. It brings up an interesting issue with operator overloading, though. -- Dan --------------------------------------"it's like this"------------------- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk