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

Reduced assignment operator?

8 views
Skip to first unread message

Audrey Tang

unread,
Sep 10, 2006, 11:58:28 PM9/10/06
to p6l
Consider these cases:
[=] $x, $y, $z;
[+=] $a, $b, $c;

S03 is currently inconsistent. It first says these are not supported:

The final metaoperator in Perl 6 is the reduction operator. Any
infix operator (except for non-associating operators and assignment
operators) can be surrounded by square brackets in term position to

But then implies it is on the defaulting table below:

[=]() # undef (same for all assignment operators)

I don't see an obvious problem in supporting them as a syntactic
expansion.
But would it be useful? And is there some hidden corners that I missed?

Thanks,
Audrey

Larry Wall

unread,
Sep 11, 2006, 1:51:31 PM9/11/06
to p6l
On Mon, Sep 11, 2006 at 11:58:28AM +0800, Audrey Tang wrote:
: Consider these cases:

: [=] $x, $y, $z;
: [+=] $a, $b, $c;
:
: S03 is currently inconsistent. It first says these are not supported:
:
: The final metaoperator in Perl 6 is the reduction operator. Any
: infix operator (except for non-associating operators and assignment
: operators) can be surrounded by square brackets in term position to
:
: But then implies it is on the defaulting table below:
:
: [=]() # undef (same for all assignment operators)
:
: I don't see an obvious problem in supporting them as a syntactic
: expansion.

Except that the left side of an = determines the scalar/list parsing
of the right side, while reduce operators are all list ops, at least
syntactically. So should this:

[=] $x, @y, 0

mean this:

$x = @y = 0;

or should it mean this:

$x = @y[0] = @y[1] = @y[2] ... = 0;

: But would it be useful? And is there some hidden corners that I missed?

Seems like

[=] @x, 0

is vaguely useful if we take the latter interpretation. (And I do
think that's the correct interpretation.) But maybe that's better
written as

@x »=« 0

in any case. On the other hand, I'm not sure how else you'd write

[+=] @x, 0

Maybe

@x = reverse [\+] reverse @x;

So I guess we can allow [=] and friends, provided it's understood that
no LHS dwimmery is done.

Larry

0 new messages