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 21:28
Subject:
Re: Pre-RFC Deep constants
Message ID:
3e48b7dc-88c3-ebc1-342d-7627cdb12305@rtij.nl

Op 09-03-2023 om 22:22 schreef Branislav Zahradník:
>
>
> On Thu, 9 Mar 2023 at 21:25, Martijn Lievaart <m@rtij.nl> wrote:
>
>     Op 09-03-2023 om 21:23 schreef Branislav Zahradník:
>>
>>
>>         Causing @nums to be read-only sounds like a good idea,
>>         actually. Immutable data is often a huge win.
>>
>>
>>     It can come with "deep copy on write" (it should not affect
>>     values it doesn't own yet data should be read-only.
>
>
>     That's also surprising behaviour. Especially when you can write
>     simply [ @nums ] instead of \@nums to achieve the same.
>
>
>
>
> Don't by confused by simplicity of examples, eg:
> my @structs = ({ ... }, { ... }, ...);
> my $var : const = [ @structs ];

That copies the contents of @structs, after which the same rules apply. 
If your point is that @structs uses { ... }, which is a reference, that 
obviously should count as a const reference. That would be the same as


my $var : const = [ { ... }, { ... }, ... ];


If that is not what you are saying, I don't get the point.


TIA,

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