--- Damian Conway <[EMAIL PROTECTED]> wrote:
> Austin Hastings wrote:
> > --- Austin Hastings <[EMAIL PROTECTED]> wrote:
> > 
> > 
> >>No, undef. OTOH, deleting @a[1] would reset it to default.
> > 
> > 
> > Ere someone flames my for using a hash keyword in an array context:
> > 
> > s/deleting/absquatulating (e.g., via pop, shift, or splice)/
> 
> Unfortunately, I don't think we can base defaultitude on the
> (non)existence of 
> an array element. You end up with some rather nasty
> action-at-a-distance.
> 
> Consider:
> 
>       my @a is default(666);
> 
>       print @a[2];    # prints 666
> 
>       @[4] = 1;
> 
>       print @a[2];    # now prints undef :-(
> 
> I think of C<is default> as specifying a mapping from an implicit or
> explicit
> C<undef> to something else.
> 

I don't understand your example. Can you explain it again, using words
of less than one syllable?

What's @[4]? Why does it (even if it's a typo from @a[4]) cause @a[2]
to become defined? (Small != dense) If it does become defined, why
doesn't it get the default value -- no-one explicitly told it to be
undef?

> I'm not compelled by the counter-argument that this makes it
> impossible to store an C<undef> in an array with a default. 
> Because the whole point of an array having a default is to 
> prevent those nasty out-of-range C<undef>s from 
> popping up in the first place.

The point of having a default is to replace those undefs with something
else. To prevent them from appearing would require rewriting ones code
in such a way that extraordinary arrefs didn't happen.

But given that I can replace undef with 'fednu' in these cases, I'd now
like to reduce/reuse/recycle my undefs back as meaningful values --
they're not reserved for the special case of LOCALE="noaquistan" any
more.
 
> And thinking of defaults as mappings leads me to conclude that it's
> entirely reasonable to allow sub refs as default specifiers, as a
> means of 
> creating computed arrays. But I'd expect that the property name is
> different 
> in that case (probably C<is computed>), so as to distinguish:

[[ code elided ]]

Yeah, that too. I like "is computed". 

=Austin

Reply via email to