From: Dilbert on
In perl 5.12.1, with reference to the exist function "perldoc -f
exist" ( see also http://perldoc.perl.org/functions/exists.html ) it
says

>> [...]
>> Although the mostly deeply nested array or hash will
>> not spring into existence just because its existence
>> was tested, any intervening ones will. Thus $ref->{"A"}
>> and $ref->{"A"}->{"B"} will spring into existence due to
>> the existence test for the $key element above.
>> [...]
>> This surprising autovivification in what does not at first
>> --or even second-- glance appear to be an lvalue context
>> may be fixed in a future release.

Has this particular case of surprising autovivification always
existed, even in perl 5.10 or 5.8 ?
From: jl_post on
On Jul 23, 10:40 am, Dilbert <dilbert1...(a)gmail.com> wrote:
> In perl 5.12.1, with reference to the exist function "perldoc -f
> exist" ( see alsohttp://perldoc.perl.org/functions/exists.html) it
> says
>
> >> [...]
> >> Although the mostly deeply nested array or hash will
> >> not spring into existence just because its existence
> >> was tested, any intervening ones will. Thus $ref->{"A"}
> >> and $ref->{"A"}->{"B"}  will spring into existence due to
> >> the existence test for the $key element above.
> >> [...]
> >> This surprising autovivification in what does not at first
> >> --or even second-- glance appear to be an lvalue context
> >> may be fixed in a future release.
>
> Has this particular case of surprising autovivification always
> existed, even in perl 5.10 or 5.8 ?


I believe so, yes. Ever since autovivification existed, this has
always been a caveat to watch out for. And I think autovivification
has been around for all of Perl 5. (But if I'm mistaken, feel free to
correct me.)

Cheers,

-- Jean-Luc
From: Dilbert on
On 23 juil, 19:04, "jl_p...(a)hotmail.com" <jl_p...(a)hotmail.com> wrote:
> On Jul 23, 10:40 am, Dilbert <dilbert1...(a)gmail.com> wrote:
> > In perl 5.12.1, with reference to the exist function "perldoc -f
> > exist" ( see alsohttp://perldoc.perl.org/functions/exists.html) it
> > says
>
> > >> [...]
> > >> Although the mostly deeply nested array or hash will
> > >> not spring into existence just because its existence
> > >> was tested, any intervening ones will. Thus $ref->{"A"}
> > >> and $ref->{"A"}->{"B"}  will spring into existence due to
> > >> the existence test for the $key element above.
> > >> [...]
> > >> This surprising autovivification in what does not at first
> > >> --or even second-- glance appear to be an lvalue context
> > >> may be fixed in a future release.
>
> > Has this particular case of surprising autovivification always
> > existed, even in perl 5.10 or 5.8 ?
>
>    I believe so, yes.  Ever since autovivification existed, this has
> always been a caveat to watch out for.  And I think autovivification
> has been around for all of Perl 5.  (But if I'm mistaken, feel free to
> correct me.)

I think you are right.
I managed to dig up perldoc.com for version 5.8.8 and it has exactly
the same description with regards to the exists function:

http://perldoc.perl.org/5.8.8/functions/exists.html

>> This surprising autovivification in what does not at first -- or even
>> second -- glance appear to be an lvalue context may be fixed in
>> a future release.

Let's hope that the surprising autovivification will be fixed in Perl
5.14
From: Uri Guttman on
>>>>> "D" == Dilbert <dilbert1999(a)gmail.com> writes:

D> Let's hope that the surprising autovivification will be fixed in Perl
D> 5.14

let's hope not! exists was just a function that provided no information
to the hash expression it was checking. the autoviv happens in the hash
lookup no matter what the outer code is doing. changing that could break
existing code which is a bad thing and the p5p people know that. perl 6
is planning on changing that. maybe a future perl could deal with this
but only enabled under a pragma like other new features.

uri

--
Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
From: Ilya Zakharevich on
On 2010-07-23, Uri Guttman <uri(a)StemSystems.com> wrote:
>>>>>> "D" == Dilbert <dilbert1999(a)gmail.com> writes:
>
> D> Let's hope that the surprising autovivification will be fixed in Perl
> D> 5.14

> let's hope not!

lets hope yes

> exists was just a function that provided no information
> to the hash expression it was checking.

.... which in 99.9999% of cases is not what the intent was.

> the autoviv happens in the hash
> lookup no matter what the outer code is doing. changing that could break
> existing code

True. So one may hook it on `use 5.14' or whatever.

Ilya