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

Re: [PATCH for discussion] clamp, round #2

Thread Previous | Thread Next
Nick Ing-Simmons
August 1, 2001 03:31
Re: [PATCH for discussion] clamp, round #2
Message ID:
Jeffrey Friedl <> writes:
>Nick Ing-Simmons <> wrote:
>|> The completeness of your patches is a joy, but IMHO:
>|> while it is now using SvREADONLY it is _still_ adding 
>|> the SVh_CLAMP_ACCESS flag which was what the SvREADONLY proposal 
>|> was supposed to avoid.
>I did so to support the ability to clamp access, which as far as I can tell
>does require another bit. Being readonly and having access clamped are
>really orthogonal (a fancy way to say "unrelated" :-), so I don't see a way
>to implement them both with one bit.

I seem to be missing something here. I agree they are orthogonal, and need 
more than one bit. I am proposing that a "read only hash with N members"
uses N+1 bits and a "clamped hash" uses 1 bit - thus:

A. Setting "the" bit on the HV to say "keys are fixed" (i.e. clamp).
B. Setting "the" bit on the SVs that are the values to say "cannot change value".

So a clamped hash just has the bit set on the HV.
A fully readonly hash has the bit set on the HV and on all the values.
As each entity only needs one bit existing SvREADONLY bit can be used.

Can you please explain what semantic that implementation lacks compared
to yours?

Then explain why this cannot be done with 'magic' ;-)

Nick Ing-Simmons

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About