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

SV: [PATCH] core-only patch for clamp/readonly hashes

Thread Previous
From:
Arthur Bergman
Date:
October 31, 2001 12:32
Subject:
SV: [PATCH] core-only patch for clamp/readonly hashes
Message ID:
077d01c1624c$096a9120$052aa8c0@foo

> > >+=item Can't access nonexistant key {%s} of readonly/clamped hash
> > 
> > That "clamped" word has IMHO got to go ...
> 
> How about "restricted"?
> 
> > frozen makes a little more sense perhaps but I am still unclear what the
> > specification is. Author and I yesterday described what semantics
> > of SvREADONLY would be. We did not describe what "frozen" would be.
> > I still don't understand the semantics of "frozen".
> > 
> > Please describe the semantics of "frozen" (don't used the clamped word)
> > explaining how it differs from READONLY.
> 
> If I got it right: at the moment of "restricting" the hash the keys
> that exist become the only allowed keys.  No new elements with new
> keys can be added.  Existing elements can be deleted, though (and
> there the "magic marker" is used), and the elements can be added back.
> 
> This is a subset of READONLY, in that with READONLY *no* changes
> are allowed.
> 
>                 add     delete  add     delete  access
>                 old     old     new     new
> READONLY        -       -       -       -       +
> restricted      +       +       -       -       +
> normal          +       +       +       +       +
> 
> -- 
> $jhi++; # http://www.iki.fi/jhi/
>         # There is this special biologist word we use for 'stable'.
>         # It is 'dead'. -- Jack Cohen
> 

I disagree.

my $foo = \$foo{"foo"} is reason enough not to have a flag on a hash to set its scalars to readonly;

To do that we need to itirate the hash and turn them on readonly.

I agree with Nick here I think.

SvREADONLY on a hash makes it impossible to add or delete keys
keys returns all keys
exists returns false on keys wich are PL_sv_undef

This can be implmented with minimal fuss and minimal checks in the core.

Arthur



Thread Previous


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