Não é mais possível fazer postagens ou usar assinaturas novas da Usenet nos Grupos do Google. O conteúdo histórico continua disponível.
Dismiss

Reduced assignment operator?

9 visualizações
Pular para a primeira mensagem não lida

Audrey Tang

não lida,
10 de set. de 2006, 23:58:2810/09/2006
para 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

não lida,
11 de set. de 2006, 13:51:3111/09/2006
para 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 nova mensagem