Subject: | Mutating references to the return values of getters mutates the contents of the hash |
Consider the output of
perl -e 'package Foo; use Mouse; has bar => (is => "ro"); my $o = bless
{bar => 1}; warn ${\$o->bar}++ for 1..5'
(outputs 1 through 5)
vs
perl -e 'package Foo; use Moose; has bar => (is => "ro"); my $o = bless
{bar => 1}; warn ${\$o->bar}++ for 1..5'
(outputs 1, 5 times)
What's worse Mouse is inconsistent with itself:
MOUSE_PUREPERL=1 perl -e 'package Foo; use Mouse; has bar => (is =>
"ro"); my $o = bless {bar => 1}; warn ${\$o->bar}++ for 1..5'
(outputs 1, 5 times)