[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: exists $foo[7] and delete $foo[7]



On Thu, 13 Jan 2000 09:59:58 +0100, "Matthias Urlichs" wrote:
>Gurusamy Sarathy:
>> Starting to fix some pesky artificial limitation in pseudo-hashes
>> that I happened to bump into, I ended up having to hack in support
>> for delete() and exists() on arrays.  Comments welcome.
>> 
>Neat. What happens to the length of the array if you delete first the
>next-to-last and then the last element?

The semantics are such that there can never be any uninitialized elements
at the end of the array.

    % perl -lwe '@x = 0..2; delete $x[1]; print @x; delete $x[2]; print @x'
    2
    0

scalar(@array) and $#array are still related in the same way as before,
but it _would_ be semantically cleaner for the former returning just the
number of initialized values.  But we really can't do that without
breaking compatibility.


Sarathy
gsar@ActiveState.com


Follow-Ups from:
Pete Jordan <pjordan1@email.mot.com>
References to:
"Matthias Urlichs" <smurf@noris.net>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]