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

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

Thread Previous | Thread Next
From:
John P. Linderman
Date:
July 19, 2001 11:29
Subject:
Re: [PATCH for discussion] new feature: clamp %hash
Message ID:
200107191829.OAA94476@raptor.research.att.com

> 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About