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

Re: Clamp, wherefor art thou

Thread Previous | Thread Next
Jarkko Hietaniemi
October 30, 2001 09:30
Re: Clamp, wherefor art thou
Message ID:
Thus spake Arthur:
> IMHO we should let SvREADONLY have a meaning on AVs and HVs.

That would solve a part of the problem, yes.

A potential plan, assuming we end up doing something about all this:

(1) Make SvREADONLY work on AVs and HVs, meaning no modifying
    the array (no push/pop/..., no setting or deleting elements)
    or the hash (no setting or deleting elements) 
(2) As Arthur points out, making the elements readonly is best
    done in a separate iteration step.  KISS.
(3) Limiting the set of acceptable keys could probably be done
    by having an optional callback to filter the keys (or indices).
    Would we need different callbacks for setting/deleting/accessing?

Summary: separate the issues into smaller ones.

I also notice that Scalar::Util has a test, readonly(SCALAR),
but nothing for setring the readonlyness.  Which is probably good,
clearing readonlyness of string literals would really not be good...

> A Readonly hashes/array can not have any new items added or deleted
> to it. But it doesn't lock the contents. If you want to do that you
> can itirate over it and make them SvREADONLY.

$jhi++; #
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

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