On Mon, Nov 18, 2013 at 02:53:45PM +0100, demerphq wrote:
Recently I started trying to use Hash::Util::lock_hash() to try to
prevent people from writing to a hash. ...
If fetch did not throw an exception they would be quite useful.

I think we should change this. Either we should just allow fetches, or
make it possible to choose which behavior we want. I cant believe very
many people would want the current implementation.
The latter is quite a reasonable suggestion. If an \%options argument was
added to lock_hash (and lock_hash_recurse etc), e.g.:

     my %myhash;
     lock_hash( %myhash, { allow_nonexistent_read => } );

...this would both preserve the existing default behaviour for all current
users (therefore not breaking anyone's code), but also allowing for many
more usecases, such as dropping in just this one line to get strict write
behaviour (but not strict read).


Search Discussions

Discussion Posts


Follow ups

Related Discussions



site design / logo © 2021 Grokbase