Michael Lazzaro <[EMAIL PROTECTED]> writes: > 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>.
AAARGH, *runs for shelter* Setting an element to a leagal value, results in a different value to be stored, making it impossible to store this value. And this is even the most prominent value of the underlying type. > Solution 2: _ANY_ other solution would require the introduction of > 'fake empty' and 'really empty', and require arrays to keep track of > the difference. > > > my Int @a is default(5); > > @a[3] = 3; # there are now 4 items in the array > @a[2]; # was autoset to undef, so returns 5 > @a[4]; # doesn't exist, so returns 5 > > @a[2] = undef; # well, it's still undef, but now mark it > # as a 'real' undef, so don't return 5. > > This is essentially adding another layer of defined-ness on each cell, > and therefore requires an additional flag be kept & checked for each > array element. While this is certainly a possibility, I worry about > the complexity it introduces. Solution 3: The autoset sets the value to the default value. my Int @a is default(5); @a[3] = 3; # there are now 4 items in the array @a[2]; # was autoset 5 so returns 5 @a[4]; # doesn't exist, so returns 5 @a[2] = undef; # set to undef, so returns undef @a[5] = @a.default # if you really want to reset something to # default. BTW there are now 6 items in # the array. returns 5 @a[4]; # is now autoset to 5 so it remains 5 The default default value is the empty value of the base type. my Int @a; is the same as my Int @a is default(undef); bye b. -- Juergen Boemmels [EMAIL PROTECTED] Fachbereich Physik Tel: ++49-(0)631-205-2817 Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906 PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47