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

Re: Pre-RFC Deep constants

Thread Previous | Thread Next
From:
Martijn Lievaart
Date:
March 9, 2023 20:21
Subject:
Re: Pre-RFC Deep constants
Message ID:
5e9d9008-e106-07c7-7c93-d5a1883928bc@rtij.nl
Op 09-03-2023 om 21:14 schreef Ovid:
> On Thu, Mar 9, 2023 at 8:59 PM Dan Book <grinnz@gmail.com> wrote:
>
>     On Thu, Mar 9, 2023 at 2:50 PM Paul "LeoNerd" Evans
>     <leonerd@leonerd.org.uk> wrote:
>
>         To me what people are looking for is read only structures.
>         Thus 1. we need an actual read only mechanism for hashes
>         (restricted hashes are too restrictive for this purpose), and
>         2. in your example the declaration would cause @nums to also
>         become read only.
>
>
> Causing @nums to be read-only sounds like a good idea, actually. 
> Immutable data is often a huge win. The downside is when someone tries 
> to mutate @nums. We'd want a mechanism to tell the developer how and 
> where the variable became read-only. That introduces its own set of 
> problems, particularly if it's happened multiple times.


I think that would lead to very surprising behaviour. If @num itself is 
not const, I would expect this construct to either die, or make the 
reference RO but not @num itself.


M4


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