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

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

Thread Previous | Thread Next
John P. Linderman
July 19, 2001 11:29
Re: [PATCH for discussion] new feature: clamp %hash
Message ID:

> Jeffrey Friedl laid this on us:
> I have long wished that I could mark a hash such that no new keys could
> be added to it -- sort of like a "use strict" for hashes in that if you
> intended
> 	$foo->{Quiet} = 1;
> and by accident typed
> 	$foo->{Quite} = 1;
> you'd get an error.

You have my vote.  As I noted some time ago,
I all too often write

use strict;

sub setsomething {
    my ($self, $value);     # = @_ omitted by accident
    $self->{something} = $value;

and $self autovivifies so there's no warning.  If I can somehow
force $self to be ``clamped'', I could get the warning I wanted.
-- jpl

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