Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hyperoperators and dimensional extension

6 views
Skip to first unread message

Brent Dax

unread,
Sep 18, 2002, 3:04:38 AM9/18/02
to Perl6 Language List
The Apocalypse on operators says that if one of the operands of a
hyperoperator is a scalar, then that scalar is (nominally) treated as an
array of copies of that scalar. In other words:

my $foo=1;
my @bar=(2, 3, 4);

my @baz=$foo ^+ @bar; # @baz=(3, 4, 5)

Does that extend to multiple dimensions?

my @foo=(1, 2; 3, 4);
my @bar=(5, 6);

my @baz=@foo ^+ @bar; # Is @baz=(6, 8; 8, 10)?

How does that interact with ragged arrays?

my @foo=([1, 2], 3; 4, [5, 6]);
my @bar=(7, 8);

my @baz=@foo ^+ @bar; # ???

--Brent Dax <bren...@cpan.org>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

Wire telegraph is a kind of a very, very long cat. You pull his tail in
New York and his head is meowing in Los Angeles. And radio operates
exactly the same way. The only difference is that there is no cat.
--Albert Einstein (explaining radio)

Dan Sugalski

unread,
Sep 18, 2002, 10:21:43 AM9/18/02
to Perl6 Language List
At 12:04 AM -0700 9/18/02, Brent Dax wrote:
>The Apocalypse on operators says that if one of the operands of a
>hyperoperator is a scalar, then that scalar is (nominally) treated as an
>array of copies of that scalar. In other words:
>
> my $foo=1;
> my @bar=(2, 3, 4);
>
> my @baz=$foo ^+ @bar; # @baz=(3, 4, 5)
>
>Does that extend to multiple dimensions?

Sort of, yes.

Basically the behaviour of hyper-operated operators is delegated via
multimethod dispatch to the hyper-operator functions. By default the
base perl variables will expand themselves out, but the engine itself
won't enforce this, as the classes can potentially overload the
hyper-operators.

So if the multiple-dimensional aggregate provides a proper "operate
against a single scalar" method that goes multidimensionally, then
we'll do that. If it doesn't, we won't.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Brent Dax

unread,
Sep 19, 2002, 11:27:37 AM9/19/02
to Dan Sugalski, Perl6 Language List
Dan Sugalski:
# Sort of, yes.
#
# Basically the behaviour of hyper-operated operators is delegated via
^^^^^^^^^
Spending time in England lately? ;^)

# multimethod dispatch to the hyper-operator functions. By default the

Well, yeah. But that doesn't really answer my question. :^) What's
the *language-level* behavior?

Dan Sugalski

unread,
Sep 19, 2002, 11:50:56 AM9/19/02
to Brent Dax, Perl6 Language List
At 8:27 AM -0700 9/19/02, Brent Dax wrote:
>Dan Sugalski:
># Sort of, yes.
>#
># Basically the behaviour of hyper-operated operators is delegated via
> ^^^^^^^^^
>Spending time in England lately? ;^)

Why, yes, actually. :-P But I've been using Pompous English Spelling for years.

># multimethod dispatch to the hyper-operator functions. By default the
>
>Well, yeah. But that doesn't really answer my question. :^) What's
>the *language-level* behavior?

Well, it does, though. Saying it's delegated to the variables and
they have a default behavior's different than saying "this is the
behaviour".

0 new messages