--- Michael Lazzaro <[EMAIL PROTECTED]> wrote:

> Right, we just can't do the 'undef' thing.  OK, so let me see if this
> is right yet:
> 
>     my Int @a is default(2);
>     @a[5] = 5;
> 
>     @a[4];         # 2 (autofilled)
>     @a[5];         # 5
>     @a[6];         # 2 (out-of-bounds)
> 
>     undef @a[5];   # undefining the element sets it to the default
>     @a[5];         # 2
> 
>     @a[5] = undef; # same as above
>     @a[5];         # 2

undef.

I feel like the duck in those AFLAC commercials.

undef!

undef!!

@a is an array of Int (not int) and can store undef, so no error occurs
when you make the assignment. But now I, the programmer, am saying that
of my own volition I want an undef in there, not a 2. If I wanted @a[5]
to take on the default value, I'd say so: C<@a[5] = @a.default;>

>     my int @a is default(2);
> 
>     @a[4];         # 2 (autofilled)
>     @a[5];         # 5
>     @a[6];         # 2 (out-of-bounds)
> 
>     undef @a[5];   # 0 (Warning: using undef in int context, autoconv
> to 0)

Like delete @a[5]. Sets value to @a.default;

>     @a[5] = undef; # 0 (Warning: using undef in int context, autoconv
> to 0)

Frankly, I think that this should be a compile time error, while 

$b = undef;
@a[5] = $b;

should be a runtime warning.

>     @a[5];         # 0
> 
>     @a[5] = 0;     # nothing special about this
>     @a[5];         # 0
> 
> Can everyone buy that?

Sure.

=Austin


Reply via email to