> Solution 1:  If you attempt to SET a cell to it's 'empty value', it
> will be set to it's default:
>
>      my int @a is default(5);  #
>      @a[5] = 0;                # actually sets it to it's 'empty value',
>
> 5
>      @a[5] = undef;            # autocnv to 0, + warning, still sets to
> 5
>
>      my Int @a is default(5);  # NOTE difference in type!
>      @a[5] = 0;                # THIS really does set it to 0
>      @a[5] = undef;            # and this sets it to 5
>
> So you can't set something to its type's own empty value, because it
> will, by definition, thereafter return it's "overloaded" empty value,
> <def>.
> -----
>
> In spite of the perhaps surprising nature of solution 1, I think it is
> probably the more correct solution, if you really insist on putting a
> default value on a primitive-typed array.  As it points out, you can
> still get both behaviors, simply by choosing int vs. Int, str vs. Str,
> etc.

OK, it sounds reasonable to me, for those cases where the 'empty value' is
undef ...

but if I have an array of #s ...
I have the list of people I invited to my wedding.
I default the # of people attending to 2 (inviting couples or "& Friend") ...
Joe responds, he's coming alone (ok, so i set him to a 1)
Karen is bringing her kids (so 4)
Fred can't come.  That's a 0.  Which is a 2.  But he's not coming, so the
2 is really a 0, but I can't say 0, b/c 0 is "empty" and becomes "default"
2 ...


Likewise for strings.  I default it to explicitly say "UNKNOWN" so I know
what's not known, but now when I find out it doesn't exist ("What's John
Doe's middle name?") I can't say that.  The answer then is "UNKNOWN" so
"John Doe" became "John UNKNOWN Doe" due to a flawed (IMO) functional
limitation ...

This is also why i (somewhat facetiously) suggested "undef but really",
although it doesn't help in this case b/c I'm wanting to set it to 0, and
saying "attendees[23] = 0 but really" looks wrong ... so maybe the "but
really" would be for setting to default ('empty value') if you had need
and used it in assignment (but undef @attendees[23] would, i think, still
make it 'empty val' b/c i'm not assigning a value to it, i'm unassigning
the value I've given it, which is a distinction that I think may be
relevant ...)

--attriel


Reply via email to