Open lizmat opened 1 year ago
Propose to:
Capture
being a value typeis raw
from AT-POS
/ AT-KEY
)Ideally to be done with a language level check, but I think that will turn out to be pretty hard to do.
The primary purpose of Capture
in the language is to model an argument list, and arguments may be mutated by is rw
parameters. For example, consider:
sub foo($p is rw) {
$p++;
}
my $x = 1;
my \c = \($x);
foo(|c);
say c;
@jnthn So then it shouldn't be a value type then?
Correct, although it'd make sense for snapshot equality (eqv
) to work.
Capture
instances are currently implemented as being a value type (basically since https://github.com/rakudo/rakudo/commit/c855a0f439 ).However, since https://github.com/Raku/old-issue-tracker/issues/4360 it has made elements of it mutable (if they were created with containers).
If an element in a
Capture
is changed, it's associated.WHICH
will also change. This violates the principle of immutability of value types.Making
Capture
instances immutable, breaks spectests. Making theCapture
class an object type, also breaks spectests.