develooper Front page | perl.perl5.porters | Postings from March 2023

Re: Pre-RFC Deep constants

Thread Previous | Thread Next
March 12, 2023 21:44
Re: Pre-RFC Deep constants
Message ID:
On Sun, 12 Mar 2023 at 16:25, demerphq <> wrote:

> On Sat, 11 Mar 2023 at 16:50, demerphq <> wrote:
>> Like I said, it turns out that reasonable people can disagree on what a
>> constant hash should be. :-) I really wish we didnt have restricted hashes
>> getting in the way, simple "readonly" hashes would be much more useful than
>> restricted hashes are.
>> MMMM, I wonder if there is a way we can extend restricted hashes so they
>> behave as people would expect a readonly/constant hash to behave without
>> throwing out restricted hashes entirely. Maybe something like
>> lock_hash(\%hash, undef); ? Eg, the undef would signal "allow any key".
>> Hrmmmm...... Watch this space, maybe I can come up with a hack for this.
> Turns out the important part of this is easy to do. I have a POC working
> on my local build, I will push a patch in the next day or two.

Effectively Hash::Util::protect_hash_recursive() can be used to create a
"constant hash", including anything it contains.

It needs more testing which is why the pull is marked as draft.


perl -Mre=debug -e "/just|another|perl|hacker/"

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