develooper Front page | perl.perl5.porters | Postings from July 2019

Re: [perl #133809] Perl silently adds a key to hash

Thread Previous | Thread Next
From:
Dan Book
Date:
July 13, 2019 22:37
Subject:
Re: [perl #133809] Perl silently adds a key to hash
Message ID:
CABMkAVUze38crkaFUkwJgwUKx+WmeEPBophu1miFJftX1j3wcg@mail.gmail.com
On Sat, Jul 13, 2019 at 5:21 PM Deven T. Corzine <deven@ties.org> wrote:

> On Sat, Jul 13, 2019 at 5:03 PM demerphq <demerphq@gmail.com> wrote:
>
>> On Sat, 13 Jul 2019, 19:42 Deven T. Corzine, <deven@ties.org> wrote:
>>
>>> I'm sorry, I didn't mean to cause any drama or dispute any decisions by
>>> Larry under Rule 1.  My bad.
>>>
>>> I would love to have the other discussion about whether the current
>>> behavior could be changed (perhaps with a pragma) to avoid autovivification
>>> except when actually required to store new data.  I do believe that most
>>> Perl programmers would consider that more intuitive.  (Leon has a good
>>> point that nobody is arguing otherwise!)
>>>
>>> I suspect that many Perl programmers would appreciate such a change,
>>> since code often needs to be added solely to prevent unwanted "read-only"
>>> autovivification..
>>>
>>
>>
>> I don't think we can change the default behaviour, on the other hand I
>> think core should own 'no autovivification' and make it as efficient as
>> possible.
>>
>
> Would it be so bad, to change the default behavior -- perhaps with a
> deprecation cycle?  It's not like Perl releases *never* break existing
> code.  Here's a post from just last month about Perl 5.30 breaking existing
> code due to deprecation of my() in false conditionals:
>
>
> https://dev.to/mitchjacksontech/perl-5-30-deprecates-use-of-my-in-a-false-conditional-55bg
>
> Actually, I wonder if changing the autovivification behavior might
> actually FIX more code than it breaks!  (It's plausible, I think...)
>

Yes. Full stop. Tons of code relies on autovivification.

-Dan

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