New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autovivification should be ignored when testing for existence #11846
Comments
From rcolvin@people.net.auCreated by rcolvin@people.net.auThis is a bug report for perl from rcolvin@people.net.au, ----------------------------------------------------------------- A simple code example: # perl -v our %list; $list{A}{sub} = "VALUE(A)"; print "LIST\n"; print "TEST #1: Output TRUE if \$list{A}{sub} present, otherwise output nothing: EXPECT 'TRUE'\n"; print "TEST #2: Ouput TRUE if \$list{C}{sub} present, otherwise output nothing: EXPECT nothing\n"; print "TEST #3: Output LIST again, \$list{C} should not be listed\n"; print "TEST #4: Output TRUE if \$list{D}{sub} defined, otherwise output nothing: EXPECT nothing\n"; print "TEST #5: Output LIST again, \$list{D} should not be listed\n"; print print "TEST #6: Output TRUE if \$list{E}{sub} exists, otherwise output nothing: EXPECT nothing\n"; print "TEST #7: Output LIST again, \$list{E} should not be listed\n"; print print "TEST #8: Output TRUE if \$list{F}{sub}{sub2} defined, otherwise output nothing: EXPECT nothing\n"; print "TEST #9: Output LIST again, \$list{E} should not be listed\n"; produces the following output: LIST TEST #1: Output TRUE if $list{A}{sub} present, otherwise output nothing: EXPECT 'TRUE' Thus, it would be useful if autovivification would ignore creating the top level key(s) when exit or defined is used. Or at least an easy way to disable autovivification in the language rather than having to change code flow or use Perl Info
|
From zefram@fysh.orgRobert Colvin wrote:
It's too late to change the default Perl behaviour in this -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From rcolvin@people.net.auOn Wed Jan 04 08:48:23 2012, zefram@fysh.org wrote:
Zefram, agreed, and I threw the autovivification module in and it tested fine. I understand that it is too late to change, hence its severity is The pragmatic module however is not always a solution, in some /Rob |
From @ikegamiOn Wed, Jan 4, 2012 at 8:04 AM, Robert Colvin <perlbug-followup@perl.org>wrote:
The operand of C<< exists $list{E}{sub} >> is evaluated before C<< exists
On Wed, Jan 4, 2012 at 11:47 AM, Zefram <zefram@fysh.org> wrote:
It seems to be this is a major complaint among Perl's users. Do we want to - Eric |
From @HugmeirOn Wed, Jan 4, 2012 at 6:08 PM, Eric Brine <ikegami@adaelis.com> wrote:
Can autovivification or something similar get into the core instead? |
From @rurbanOn Jan 4, 2012 3:08 PM, "Eric Brine" <ikegami@adaelis.com> wrote:
Absolutely!
|
From dcmertens.perl@gmail.comOn Wed, Jan 4, 2012 at 3:08 PM, Eric Brine <ikegami@adaelis.com> wrote:
If it is such a major complaint, how might it go about getting changed? I'm So, what does it take to get something like this into core? David -- |
From zefram@fysh.orgRobert Colvin via RT wrote:
It's not a bug. The behaviour is perfectly consistent across operators. -zefram |
From @ikegamiOn Thu, Jan 5, 2012 at 9:43 AM, David Mertens <dcmertens.perl@gmail.com>wrote:
The current (well reasoned) desire is to *remove* modules from the perl You're saying this module works perfectly well without being bundled into - Eric |
From rcolvin@people.net.auOn Thu Jan 05 06:44:30 2012,
this is certainly one solution, |
From rcolvin@people.net.auOn Thu Jan 05 08:18:43 2012,
indeed it may be consistent, |
From rcolvin@people.net.auOn Thu Jan 05 14:20:12 2012,
true, but pre-supposes that this as I stated earlier, I still I would love to be persuaded finally whilst this module dies if the consensus is that it's not |
From @pjcjOn Thu, Jan 05, 2012 at 02:58:30PM -0800, Robert Colvin via RT wrote:
From perldoc -f exists: This surprising autovivification in what does not at first--or even -- |
From @demerphqOn 5 January 2012 23:19, Eric Brine <ikegami@adaelis.com> wrote:
If the (unthinking) position of "if we can remove it from the core The reason to do something should never be because we *can*, it should
I consider this module to be in the same category as Scalar::Util and cheers, -- |
From @cpansproutOn Fri Jan 06 08:53:00 2012, demerphq wrote:
I think it would be better to make it part of the core itself, resulting Then, we should probably consider whether it does everything correctly. What is the *concept* behind not having exists $foo{bar}{baz} autovivify We need to come up with a concept that works (e.g., autovivification is Otherwise we run the risk of having a model that is not self-consistent, -- Father Chrysostomos |
From @druud62On 2012-01-05 23:58, Robert Colvin via RT wrote:
Reminds me: This also changes the state of $a: my $a = "2"; If that $a is on a shared memory page, and that numeric test happens in -- |
From @demerphqOn 6 January 2012 20:31, Father Chrysostomos via RT
I am fine with that. In fact I generally prefer not to have to use a
Agreed. Yves -- |
From @ap* Father Chrysostomos via RT <perlbug-followup@perl.org> [2012-01-06 20:35]:
That sounds good to me. Off the bat I can’t think of a case where I want Maybe Abigail can think of such a case, though. Regards, |
From kstarsinic@gmail.comI'm looping in Phil Moore, as I recall that autovivification is an Phil, my apologies in advance if you no longer care. - Kurt On Sun, Jan 8, 2012 at 7:39 PM, Aristotle Pagaltzis <pagaltzis@gmx.de> wrote:
|
From @wphillipmooreThis is pretty amusing.... First of all, I am flattered that my 15 I've been out of the perl5-porters loop for too long, and my knowledge The issues I had at the time were primarily due to the fact that while if ( $a->{b}->{c}->{d} ) { and the mere existence of the the intermediate references was if ( exists $a->{b}->{c} ) { Then, BEFORE the change, that deep key didn't exist. AFTER the if ( exists $a->{b} and exists $a->{b}->{c} ) Although, I don't recall if "and" had been added by that time, either. Phil (who is now going to spend the rest of the evening fondly On Tue, Jan 10, 2012 at 4:44 PM, Kurt Starsinic <kstarsinic@gmail.com> wrote:
|
From @nwc10On Tue, Jan 10, 2012 at 05:02:49PM -0500, Phillip Moore wrote:
I'm not sure which change you mean, but I don't think that it can exactly $ ~/Sandpit/5000/bin/perl -le 'if ( $a->{b}->{c}->{d} ) { print }; if ( exists $ perl -le 'if ( $a->{b}->{c}->{d} ) { print }; if ( exists The only references I can spot to /autoviv/ in the changelog is about I think that a relevant thread starts here: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1997-07/msg01063.html and Larry's response is interesting: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1997-07/msg01091.html Alan writes: Nicholas Clark |
Migrated from rt.perl.org#107528 (status was 'open')
Searchable as RT107528$
The text was updated successfully, but these errors were encountered: