develooper Front page | perl.perl5.porters | Postings from October 2005

Time to fix @foo->[0]? (was: [PATCH] Re: [perl #37350] $#{@$aref} in debugger gives: Bizarre copy of ARRAY in leave)

From:
Robin Houston
Date:
October 21, 2005 09:25
Subject:
Time to fix @foo->[0]? (was: [PATCH] Re: [perl #37350] $#{@$aref} in debugger gives: Bizarre copy of ARRAY in leave)
Message ID:
20051021134754.GA10690@rpc142.cs.man.ac.uk
On Wed, Oct 19, 2005 at 11:15:10PM +0200, Rafael Garcia-Suarez wrote:
> Thanks, applied as change #25808 to bleadperl.

Is this a good opportunity to revisit the other related issue:
that of @foo->[0] and %foo->{bar}?

Someone (I think it might have been me) added a warning at some
point, so this now warns "Using an array as a reference is
deprecated".

In line with Yitzchak's observation about $#{@foo}, the "correct"
behaviour of @foo->[0] is surely for it to behave like ("".@foo)->[0].
This is an error under 'use strict', so it would only cause silent
breakage for non-strict scripts -- and the deprecation warning has
been in place since 5.8.0.

If there's some sort of consensus that this is the right thing
to do, I'm happy to look into implementing it.

Robin



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About