I was going to submit this as a Rakudo bug report, but I'm not sure
it's (a natural consequence of) spec, so I'll ask here on p6l instead.

I already know I can do all of the following:

 $a.postcircumfix:<[ ]>(42);
 $a = $a.postcircumfix:<[ ]>(42);
 $a.=postcircumfix:<[ ]>(42);

But can I do this?


In other words, would the .=[...] syntax unambiguously mean
"positionally index the LHS and assign the result back to it"?

Same question for prefix .=[...]. And same question, of course, for
the other postcircumfix indexing operators. And, tentatively, for
method call syntax as well, even though the semantics would be "invoke
the LHS with these paramters and assign the return value back to it".

Rakudo currently doesn't recognize this syntax.

$ perl6 -e 'my @a = <zero one two>; my $a = @a; $a.=[2]; say $a'
Could not find non-existent sub !.=

(Same result for hash access, function calls, and the prefix forms.)

STD.pm doesn't seem to have a problem with it.

$ std 'my $a; $a.=[42]'
ok 0:01.19 2487m

$ std 'my $a; $a.={"foo"}'
ok 0:01.16 2487m

$ std 'my $a; $a.=()'
ok 0:01.11 2487m

$ std '.=[42]'
ok 0:01.10 2479m

$ std '.={"foo"}'
ok 0:01.04 2479m

$ std '.=()'
ok 0:01.01 2479m

I have not checked to see what it parses the syntax into, though.

// Carl

Reply via email to