Hi,

I came to this

12:51 <@moritz_> rakudo: my $x = 3; say $x, ' ', ++$x;
12:51 < p6eval> rakudo 7b81c0: OUTPUT«4 4␤»
12:51 <@moritz_> rakudo: my $x = 3; say $x, ' ', $x++;
12:51 < p6eval> rakudo 7b81c0: OUTPUT«4 3␤»

This looks very counter intuitive, because it looks like the arguments are evaluated right-to-left, not left-to-right. (It just looks like it, it doesn't actually happen this way; using say(~$x, ....) shows that).

Then again it might be correct, because the first positional parameter of say() (which is slurpy, but doesn't matter here) is bound to $x, and $x changes before say() is actually called.

Is it right that the parameter binds to the variable ($x), not to the number (3) (which would be immutable)? I'm sure that in the presence of "is rw" the bahviour cited above would be correct, but for 'is copy' or the default I don't see a reason for that.

Cheers,
Moritz

Reply via email to