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

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

Thread Previous | Thread Next
Yitzchak Scott-Thoennes
October 23, 2005 01:53
Re: Time to fix @foo->[0]? (was: [PATCH] Re: [perl #37350] $#{@$aref} in debugger gives: Bizarre copy of ARRAY in leave)
Message ID:
On Fri, Oct 21, 2005 at 09:51:08PM +0200, Abigail wrote:
> On Fri, Oct 21, 2005 at 02:47:54PM +0100, Robin Houston wrote:
> > 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.
> Turning '@foo->[0]' to mean '("".@foo)->[0]' is going to solve what exactly?
> While I agree that it's better to write '$foo[0]' instead of '@foo->[0]',
> I doubt anyone writes '@foo->[0]' if they want '("".@foo)->[0]'.
> One of the features of Perl is it's DWIM. '@foo->[0]' does what people mean.
> I don't see any gain in breaking that.

The only gain would be in the "keeping the rules simple" front.  I
don't know if that's reason enough in this case.  ATM I tend to think

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About