On Thu, 29 Jun 2017 03:13:07 -0700, c...@zoffix.com wrote: > On Thu, 29 Jun 2017 00:45:02 -0700, elizabeth wrote: > > Shouldn’t: > > > > sub ($ is rw) { } > > > > be a compile-time error? I mean, there is no way to actually assign > > to the anonymous variable, is there? So there is no point in the “is > > rw”. So most likely indicates a typo on the user side. > > >
Here's a less convoluted example for the last usecase. Taking an iterable with 2 rw containers, while not necessarily wanting to assign each of the items into their own variables. I'd expect the first example to error out just like the last example instead of accepting the values (or dying with inconsistent bind error): <Zoffix__> m: sub foo (@a ($ is rw, $ is rw)) { $_++ for @a }; my @a := 42, 42; foo @a; dd @a <camelia> rakudo-moar 2a8d1e: OUTPUT: «Cannot resolve caller postfix:<++>(Int); the following candidatesmatch the type but require mutable arguments: (Mu:D $a is rw) (Int:D $a is rw)The following do not match for other reasons: (Bool:D $a is rw) (Bool:U $a is …» <Zoffix__> m: sub foo (@a ($ is rw, $ is rw)) { $_++ for @a }; my @a = 42, 42; foo @a; dd @a <camelia> rakudo-moar 2a8d1e: OUTPUT: «Array @a = [43, 43]» <Zoffix__> m: sub foo (@a ($z is rw, $zz is rw)) { $_++ for @a }; my @a := 42, 42; foo @a; dd @a <camelia> rakudo-moar 2a8d1e: OUTPUT: «Parameter '$z' expected a writable container, but got Int value in sub foo at <tmp> line 1 in block <unit> at <tmp> line 1»