[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: exists $foo[7] and delete $foo[7]
Gurusamy Sarathy <gsar@ActiveState.com> wrote:
> If we made scalar(@foo) only count the initialized valuse (a.k.a values
> that exist), the following code will break:
>
> $foo[3] = 4; # @foo[0,1,2] are uninitialized, even in perl 5.005
> if (@foo > 2) {
> ...
> }
Ahh. Good point, that chap.
> I don't think we can do it. Besides, it possibly reads better to extend
> values() to do that instead.
C<scalar @array> /would/ be better IMO, but C<values(@array)> would do the
trick.
I know this is all just a side effect of pseudo-hashes, but I /like/ the
idea. There is a qualitative difference between undefined and entirely
absent as undefined is a value that a scalar can hold.
/Pete/
"THIS IS THE COMPATIBILITY POLICE.
RESTORE YOUR ORIGINAL TOKE.C AND BACK AWAY SLOWLY."
- Follow-Ups from:
-
Tom Christiansen <tchrist@chthon.perl.com>
- References to:
-
Gurusamy Sarathy <gsar@ActiveState.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]