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

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




> 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, but now can be tested with exists().

So this is a totally new feature.  It's not just a shortcut for
something that was there before.  It used to be that array values were
just scalars and had the same kinds of values as other scalars:
strings, numbers, references, etc., or undefined; now they can be
strings, nubers, references, etc., or undefined, or uninitialized.

> The effect of exists() on an array element cannot be represented using
> existing semantics, because the concept of "uninitialized array element"
> wasn't visible at the Perl level before.  But the concept is crucial
> for representing "sparseness" in arrays, which is needed by pseudo-hashes.

Could you explain why?  Because I don't understand the cruciality, and
it seems like a very bad idea to me.  In particular, I would have
thought that this:

> We're officially in the beta-building phase now, and I'm going to
> focus on making 5.5.64 as feature-complete as possible to call it
> a beta.  To do that, we need to pull together all the loose ends
> in the _existing_ features; if any of you have brand new feature
> ideas that haven't yet been aired, it is probably wise to keep them
> for 5.7.x.

would apply to anyone who wanted to make a basic change to the
semantics of arrays, and I don't understand why it doesn't.



Follow-Ups from:
Larry Wall <larry@wall.org>
References to:
Gurusamy Sarathy <gsar@ActiveState.com>

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