Subject: | can't bless a Data::Locked structure, can't lock a blessed object |
Under Perl 5.12.1, the following example in Data::Lock documentation
doesn't work (generates an error "Modification of a read-only value
attempted" when doing the bless) :
If you want to make $o->{foo} immutable, Define Foo::new like:
sub new {
my $pkg = shift;
dlock(my $self = { @_ });
bless $self, $pkg
}
Conversely, the following example in Attribute::Constant is wrong,
because locking a blessed object is a no-op.
dlock(my $p = Bar->new(
1, 2, 3
));
So in the end there is no way to lock a blessed object, neither before
blessing it, nor after !