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

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

Thread Previous | Thread Next
From:
Graham Barr
Date:
July 19, 2001 12:41
Subject:
Re: [PATCH for discussion] new feature: clamp %hash
Message ID:
20010719203915.L51129@pobox.com
On Thu, Jul 19, 2001 at 09:26:22PM +0200, H.Merijn Brand wrote:
> On Thu 19 Jul 2001 21:05, Craig Milo Rogers <rogers@ISI.EDU> wrote:
> > >To clamp down on a hash and disallow access to nonexistant keys:
> > >   clamp %hash, 1
> > >
> > >To unclamp:
> > >   clamp %hash, 0
> > >
> > >To query
> > >   my $clamped = clamp %hash;
> > 
> >     clamp %hash;
> >     unclamp %hasn;
> >     my $clampishness = clamped %hash;
> 
> Which would make Jeffrey's other example very tedious:
> 
> 	my $prev = clamp %$ref, 0;
> 	$ref->{NewKey} = 1;
> 	clamp %$ref, $prev;
> =>
> 	my $prev = clamped %$ref;
> 	unclamp %$ref;
> 	$ref->{NewKey} = 1;
> 	$prev and clamp %$ref;
> 
> Better? Don't think so.

But it would at least be consistent with tie, tied, untie

And IMO consistency matters.

Graham.

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