After some discussion on IRC, we have all declarators implying a signature
syntax, either with parens for full sig or without for a limited one arg
syntax:

    my Int $x = 1;
    my (Int $x where Odd, Dog $spot = fido()) := (1,$lassie);

The sigil or the parens still control the context of the right side in
the case of assignment, but the listop form of either = or := causes the
right side to parse as a list argument that doesn't need parens, just as
with ordinary list operators.  The scalar form is unaffected, so

    loop($a = 1, $b = 2; ; $a++, $b++) {...}

still works.

In the case of

    my ($a, $b, $c) = 1,2,3;

the left side is parsed as a signature and "degrades" to an ordinary lvalue
list, but since "my" already restricts what can occur in such a list, that's 
fine.

If you wish to bind to a signature without a declarator, you have to use
the colon form of sig:

    :($a,$b,$c) := 1,2,3;

Assignment to a sig does binding but maintains copy semantics so that

    my $a = $b;
    my ($a,$c) = $b,$d;

do not alias, and

    :($a,$b) = $b,$a

swaps values rather than clobbering one of them, because the binding is to
temp copies.

my $a, $b, $c;

is still an error, generally caught by the fact that $b hasn't been declared.

I'm sure I've left out something important...

Larry

Reply via email to