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

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

Thread Previous | Thread Next
From:
H . Merijn Brand
Date:
July 19, 2001 12:31
Subject:
Re: [PATCH for discussion] new feature: clamp %hash
Message ID:
20010719212340.E263.H.M.BRAND@hccnet.nl
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.

> 	I think that these are cleaner than having the boolean second
> parameter to "clamp".  Otherwise, I'd welcome this feature.
> 
> 					Craig Milo Rogers


-- 
H.Merijn Brand    Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl-5.6.1, 5.7.1 & 628 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
     WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.022 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/


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