develooper Front page | perl.perl5.porters | Postings from September 2014

Hash::Util and read-only values

Thread Next
Father Chrysostomos
September 19, 2014 22:48
Hash::Util and read-only values
Message ID:
With Hash::Util::hv_store and Hash::Util::unlock_value, it is possible
to turn off the read-only flag of any scalar.

There are cases where the core uses this flag to protect things that
must not be modified.  So we need to stop Hash::Util from being able
to do this.

(I bring this up, because with lvalue references it will become easier
to do this by mistake.)

So we need to distinguish truly read-only values from values locked by

Hash::Util::unlock_value should croak for any read-only (as opposed to
locked) value.  But should Hash::Util::lock_value croak for those, or
just return?  I am inclined to think it should croak, as a successful
lock_value implies that later unlock_value will work.

Actually, since locking or unlocking an entire hash's values at
once is possible, should (un)locking silently do nothing with read-
only values?

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About