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

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



On Wed, Jan 12, 2000 at 11:34:21PM -0800, Gurusamy Sarathy wrote:
> On Thu, 13 Jan 2000 02:18:32 EST, Mark-Jason Dominus wrote:
> >
> >> 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.
> >
> >I notice that although the effect of deleting the last element of an
> >array is documented, you have not documented the behavior of delete on
> >any other element.  You only said that it `deletes' the elemnt, which
> >could mean any of several things.  In particular, you did not say
> >whether or not it is the same as `undef' in these cases.  I think you
> >should explicitly say whether it is the same as undef or splice or
> >whatever.
> 
> Basically, delete($foo[7]) makes Perl think $foo[7] is uninitialized,
> which is a different state than what results from either C<$foo[7] = undef>
> or C<undef $foo[7]>.  This uninitialized state couldn't be detected
> in earlier versions,

At least not without trying to modify it via an alias and trapping the
'attempt to modify a read-only variable' error.

I certainly support this change.

Tim.


References to:
Mark-Jason Dominus <mjd@plover.com>
Gurusamy Sarathy <gsar@ActiveState.com>

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