develooper Front page | perl.perl5.porters | Postings from September 1999

Re: The extent of double-quotish interpolation

From:
Gurusamy Sarathy
Date:
September 20, 1999 09:46
Subject:
Re: The extent of double-quotish interpolation
Message ID:
199909201650.JAA13214@activestate.com
On Sat, 28 Aug 1999 09:30:41 MDT, Tom Christiansen wrote:
>>But it's just not sensible that
>
>>    @a = (undef, undef);     # @a has two elements
>>    @b = @a[0,1];            # @b has two elements
>>    @c = (undef, undef)[0,1];# @c has *zero* elements

That's not true since 5.005_57.  See Hugo's patch that went in at
change#3406.

>>and I think this should be fixed.  However, I agree that it would be a
>>terrible blunder to fix this and break
>
>>    @a = ()[0,1];
>
>>Here, @a should have zero elements, not two.  This would be sensible and
>>leave your (getpwent)[7,0] example intact.
>
>Ah, I think I see what you mean now.  You want these to behave differently:
>
>  DB<1> print $count = @array = ((undef) x 3)[0,1,2]
>0
>  DB<2> print $count = @array = ()[0,1,2]           
>0
>
>You'd have the first version start returning three, but leave the second
>version alone.  The potential for breakage here is certainly reduced
>compared to what I misunderstood the original request to be, since there
>are fewer cases that would change.  And it's quite possible that it's
>the latter case that people rely upon more than it is the former one.
>Whether it's exclusively the latter case that matters, I wonder.  But you
>can't know what color the yolk is until you break the egg.

Omlette makers can sometimes tell without breaking anything. :-)


Sarathy
gsar@activestate.com



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