Aaron Sherman <[EMAIL PROTECTED]> wrote:

> Why does Parrot need this? What's so special about hyper operations that
> makes Parrot want to take them on?

The special thing is optimizing for integers and floats. The bad thing
is overridden »op« for aggregates holding PMCs. These might do whatever
they want, e.g.

  hyper
  Px += 4   # add 4 to each column in data base

and worse, we have two versions of delegate/tie/whatever, the aggregate
itself can provide »+« and each aggregate member can have a
different C<add> operation.

> The way I have read Perl 6's Apocalypses hyper-operations are
> essentially (sometimes lazy) operations on arrays and/or lists of
> values. So:

>       @a = @b >>+<< @c

> Is just a rather simple for loop that traverses the two lists, adding
> them together and constructing a new list. You don't need a vtable entry
> for that.

Well, yes. Except for the special case, which is nice though:

$ time parrot ih.imc  #[1]
real    0m0.370s

$ time perl i.pl      #[2]
real    0m5.656s

That'll be around a factor of twenty for an optimized build, which can
make a difference ...

leo

[1] unoptimized parrot, ih.imc from my proof of concept
[2]
$ cat i.pl
#!perl
use strict;
my (@ar); # is array of int
for (0 .. 999_999) {
    $ar[$_] = 10;
}
for (1 ..5) {
    for (0 .. 999_999) {
        $ar[$_] += 10;
    }
}
print $ar[0], $ar[999_999], "\n";

Reply via email to