[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, Jan 13, 2000 at 09:18:35AM -0800, Gurusamy Sarathy wrote:
> I should note that I'm not particularly attached to this going in for
> 5.6.  Maybe we should take a vote on whether we want to keep it or
> not.  I think I've already cast my vote by putting it in.  :-)
> 

I vote a strong NO.  I see no utility in this feature, only confusion.
delete() and exists() are well-defined for hashes.  They are not
well-defined for arrays.  Hashes and arrays are two different data
structures; they should have different manipulator functions.

Even if there were a need to provide such functionality for arrays (which I
am very skeptical of), the names delete() and exists() do not accurately
describe their proposed functionality on arrays.  delete() does not delete
an element from an array; instead, it unitializes an element of an array.  The
array will still have the same number of elements (unless the deleted
element was at the end of the array, a curious distinction).  exists() does
not determine whether an element exists in an array (that functionality is
already provided by $index <= $#array); instead, it determines whether an
existing array element has been initialized.

If you want to use delete() and exists() on arrays, you really want to use
a hash instead.

I dread the day when push(), pop(), shift(), unshift(), and splice() are
extended to work on hashes...

Ronald


Follow-Ups from:
Sam Tregar <sam@tregar.com>
Chris Nandor <pudge@pobox.com>
Gurusamy Sarathy <gsar@activestate.com>
References to:
Larry Wall <larry@wall.org>
Gurusamy Sarathy <gsar@activestate.com>

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