[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: exists $foo[7] and delete $foo[7]
Tom Christiansen <tchrist@chthon.perl.com> writes:
>>>
>>Nothing. There's nothing there, not even an undef() or an empty string.
>>That's why the array gets shorter if you delete its last value.
>
>You have to put *something* there! There's a slot. If there's not
>something there, then the slot is gone. The picture abhors a vacuum.
>Is it undef? Is it ""? Is it 0? Is it false? It it XXXXX?
>Is it Jehosaphat? :-)
NULL vs undef vs '' is the bane of Tk so my immediate guess was that
he had put NULL there rather than an SV *.
This would have to be returned to perl code as undef but the C code
could tell them apart - hence distinguishing the 'exists' but undef
which occurs with hashes:
We can say:
$hash{'foo'} = undef;
if (exists $hash{'foo'}) { ... }
we could also do
$array[12] = undef;
if (exists $array[12]) { ... }
exists does not bother me.
delete does for two reasons:
1. Why can I (apparently) delete $pseudo{'foo'}
when I can't add $pseudo{'foo'} = 'xxx'.
2. The initiated will think delete does splice.
(I have users that try and use it that way already...)
--
Nick Ing-Simmons
- References to:
-
Tom Christiansen <tchrist@chthon.perl.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]