Ok, stepping back...
there are three questions:
* Can a type be undefined
* What does an array say when asked for an element that doesn't exist
* What happens when you try to undefine something
I really think you need an attribute to clarify these.
For example, you would not say:
my int @a
but, rather
my @a is of(int)
or some such ("of" is a place-holder here that I don't much like because
it looks like "if"). In other words, the array itself is not an int. It
just contains them. You could have said:
my FunkyArray is of(int)
no?
Now, when you ask for an int that doesn't exist what do you get? By
default, I would suppose 0, but couldn't I want an integer-only data
type that *can* be undef?
If so, isn't that:
my @a is of(int but undefinable)
Ok, now we get to the meat of the matter:
my @a is of(int but undefinable), default(100)
here we have a perfectly valid thing to want. A list whose elements can
be undef or an integer, and which default to 100 when read
uninitialized.
As for the argument that testing for true non-existentness is a burden,
check out the way Perl5 does this. Hint: there's a central sv_undef, and
that's not what array buckets are initialized to....
--
Aaron Sherman <[EMAIL PROTECTED]>
This message (c) 2003 by Aaron Sherman,
and granted to the Public Domain in 2023.
Fight the DMCA and copyright extension!