I was asked to post a small summary of hyper ops for you guys.  Here it
is:

Of course to hyperize an operator you surround it with ÂÂ, or just one
of them for a unary operator.

    @a Â+Â @b
    @aÂ++

You can't necessarily override their semantics without chaning how Perl
6 interprets the syntax (i.e. grammar munge).  So for an operator ` :

    @a Â`Â @b

Always means:

    map -> $i { $a[$i] ` $b[$i] } 0..max([EMAIL PROTECTED], [EMAIL PROTECTED]);

Except that, if I recall, when one list runs out it uses a suitable,
operator-specific default.  That is, 0 for +, 1 for *, who-knows-what
for %.  I'm not certain on the details there.

When a binary op has one array and one scalar argument, the scalar side
is repeated:

    @a Â+Â 1;

Means:

    map { $_ + 1 } @a;

If you need to treat one side as scalar, you give it an explicit
context:

    @a Â+Â [EMAIL PROTECTED];     # add the length of @b to @a

Of course to Parrot that means nothing.

And hyperization can be used on any operator declared with inifx:
prefix: or postfix:  (so not things that just *look* like operators,
like ",").

    @aÂ.[4]  # Slice the fifth column of a matrix

Is legal because a subscript is a postfix operator.

Luke

Reply via email to