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 3, 2001 19:35
Subject:
Re: restricted hashes, and other readonlyness (was "clamp...")
Message ID:
20011103223507.H600@blackrider
Keep in mind I'm only talking about a hash which protects it's keys.
Protecting values is a whole 'nuther ball of wax.  Obviously you don't
want to be able to delete() a key on a read-only hash.


> I am not convinced that making one routine in an external data-base
> cache class (which is going to be a little involved anyway) is 
> worth slowing down even subset of hash accesses in every perl app even by 
> a femto-second.

Ah HA!  Here's the argument as I see it:

    Making restricted hashes as hash-like as possible will make them
    more useful.

                            vs

    Making restricted hashes as hash-like as possible will make the
    internals complicated and buggy and slow down regular hashes.

So if we can implement a hash-like restricted hashes without:

    1) Slowing down regular hashes
    2) Slowing down restricted hashes
    3) A complicated implementation

Then it's all good.

I say let's table this to-delete-or-not-to-delete argument and
implement a basic restricted hash implementation which just does:

    1) Read on disallowed key is an error
    2) Write on disallowed key is an error

And see what happens.  Then try it with

    3) delete() is an error

and see what happens there.

Good?


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
36 haikus
would scare the shit out of me.
Thank goodness for paste!
	-- Schwern

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