--- Ed Peschko <[EMAIL PROTECTED]> wrote: > > > right, and what does this all mean? I have yet to see a good > meaning > > > for > > > @array ^[+]= @array2 ... > > > > I think it's this: > > > > @a [+=] @b -> @a[x] += @b[x] > > > > @a [+]= @b -> @temp = @a [+] @b; a = @temp; > > > > Ok, so the '=' isn't being explicitly vectorized. So - > > @a ^[+]= @b; > > @a = (1,2,3,4); @b = (5,6,7,8); > > @temp = @a ^+ @b; = (1+5,2+6,3+7,4+8) = (6,8,10,12); > > @temp = (6,8,10,12); > > @a = (6,8,10,12); > > > wheras: > > @a ^+= @b; > > $a[0] += $b[0]; > $a[1] += $b[1]; > $a[2] += $b[2]; > $a[3] += $b[3]; > > $a[0] = 1 + 5; > $a[1] = 2 + 6; > $a[2] = 3 + 7; > $a[3] = 4 + 8; > > @a = (6,8,10,12); > > ie: they are exactly the same. I'd say that '=' has *implicit* > vectorization > here in the array case.
Ed, Under normal definitions, you're right. But under overload, you're seeing two different sets of operators get invoked? @temp = @a [+] @b; @a = @temp; This invokes N iterations of (multidispatch(operator:+, $a[n], $b[n])), which likely results in: N x Some_Class.new N x Underlying_type.operator:+($a[n], $b[n]) N x Some_Class.operator:= followed by one invocation of @a.operator=. Potentially useful if objects should be "rebalanced" or "snapshot" or "transactionalized" or something whenever a vector operation happens. Especially where variables are tied, or represent fanciful classes with simplified interfaces, this will be significant. OTOH: @a [+=] @b This invokes N iterations of (multidispatch(operator:+=, $a[n], $b[n])) which likely results in (if it doesn't actually IMPLEMENT): N x Underlying_type.operator:+ N x Some_Class.operator:= and nothing else. So there's no "initialize the temp object" or "close down the original @a TIE" or "whatever" getting invoked. And that can be a win, database-session-closeout-wise, or whatever your TIE'ing application happens to be. =Austin __________________________________________________ Yahoo! - We Remember 9-11: A tribute to the more than 3,000 lives lost http://dir.remember.yahoo.com/tribute