[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 10:29:26AM -0800, Gurusamy Sarathy wrote:
> On Thu, 13 Jan 2000 13:06:30 EST, Ronald J Kimball wrote:
> >If you want to use delete() and exists() on arrays, you really want to use
> >a hash instead.
> 
> Hashes take a lot more memory than arrays, or haven't you noticed?

And they both take a lot more memory than scalars, but that doesn't stop me
from using the appropriate data structure for the task at hand.

I don't mind the idea of being able to distinguish between an uninitialized
scalar and an undefined value, but:

that functionality should be available for simple scalars as well

delete() and exists() seem like the wrong names for that functionality

'uninitialized' and 'undefined' are used somewhat interchangeable already,
and I'm not sure a distinction can be cleanly added at this point


Back to the issue of pseudo-hashes for a moment...

I'm also curious, when you add this functionality to pseudo-hashes, how
will you distinguish between a key whose value has been deleted, and a key
that is not present in the hash?

$pseudo = [ {a => 1, b => 2}, 'A', 'B' ];
delete $pseudo->{a};

Would exists($pseudo->{a}) and exists($pseudo->{c}) return the same values?
This is an important distinction because you can assign to $pseudo->{a},
but not to $pseudo->{c}.

I suppose one could return '' and the other could return undef.

Ronald


Follow-Ups from:
Nick Ing-Simmons <nick@ing-simmons.net>
References to:
Ronald J Kimball <rjk@linguist.dartmouth.edu>
Gurusamy Sarathy <gsar@activestate.com>

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