Google グループは Usenet の新規の投稿と購読のサポートを終了しました。過去のコンテンツは引き続き閲覧できます。
Dismiss

Reduced assignment operator?

閲覧: 9 回
最初の未読メッセージにスキップ

Audrey Tang

未読、
2006/09/10 23:58:282006/09/10
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

未読、
2006/09/11 13:51:312006/09/11
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 件