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

Re: restricted hashes, and other readonlyness (was "clamp...")

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
November 1, 2001 10:29
Subject:
Re: restricted hashes, and other readonlyness (was "clamp...")
Message ID:
20011101132915.E7467@blackrider
On Thu, Nov 01, 2001 at 01:06:00PM -0500, Michael G Schwern wrote:
> We made these mistakes with 5.005 pseudo-hashes.

Now I remember what I really hated about 5.005 pseudo-hashes!  (Sorry,
this conversation is dredging up long repressed memories.)  Because of
all the little inconsistencies, you had to write code from the start
*knowing* that it was for pseudo-hashes, taking into account the
special meanings of keys() (which listed the allowed keys), exists()
(which told you if a key was allowed or not) and delete() (which
simply blew up).

You can rarely know from the start, with accuracy, that you're going
to need a pseudo-hash (restricted hash, whatever), so you just start
with whatever's easiest and most flexible (ie. a regular hash).  As
your code evolves, if it turns out your hashes tend to be of fixed
sets, then you'll go back and retrofit/refactor something more
sophisticated in place.  The more like regular hashes the new thing
works, the less replacing you have to do.  Ideally, you'd only want to
have to change the initialization of the hash, O(1) times,
rather than change how it is used, or O(n) times.


As you're all probably sick of hearing about 5.005 pseudo-hashes, I'll
just go stuff those memories back under the bed where I found them.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
The truth is you suck!

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