develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [PATCH for discussion] new feature: clamp %hash

Thread Previous | Thread Next
Jeffrey Friedl
July 19, 2001 12:55
Re: [PATCH for discussion] new feature: clamp %hash
Message ID:

Graham Barr <> wrote:
|> > (it's just flipping a bit, so is very low impact).
|> I am OK with adding, thats not my issue. My issue is with reading the hash.
|> ie
|>   $var = $hash{element};
|> should just continue to return undef, not croak. IMO

The feeling that motivated my wanting all this in the first place probably
was more concerned with prohibiting access to non-existant keys than with
creating new keys, since overall I'd guess that there are more accesses
than assignments. I'd certainly want to protect against typing
	if ($hash{quite}) {
instead of
	if ($hash{quiet}) {
just as I'd want to protect against 
	$hash{quite} = 1;

There's nothing stopping you from accessing any element you'd like (so
Perl's not forcing anything), but if you *do* want access limitiations to
what's currently there, I'd feel symmetrical restrictions make the most

And, since you can temporarily unclamp, it doesn't remove the functionality
you wish (it just makes it ugly). But to go the other way actually lowers
the overall functionality.

Here's an idea. It should be trivial to have two clamping bits:

 clamp %hash, CLAMP_CREATE;
 clamp %hash, CLAMP_ACCESS;
 clamp %hash, CLAMP_ALL; # same as CLAMP_ACCESS|CLAMP_CREAT
 clamp %hash, CLAMP_NONE;


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