On 20 Sep 2000 04:06:02 -0000, Perl6 RFC Librarian wrote: >Ilya Zakharevich brought up the issue of a potential problem with >objects which use blessed list references as their internal structure, >and their use as indices. Given a Bignum class, which stores its >(external) value internally as a list of integers, doing something >like: > >my $bignum = Bignum->new(23) # stored internally as [ 2, 3 ] >print $array[$bignum]; # should it print $array[23] or $array[[2,3]]? > >can be ambiguous. I'm not so sure. I think that $bignum is not >legal, under Perl5, to be an array index, and that if it is going to >be use so, it would need to be $array[$bugnum->value] anyway. Hmm... the problem is, I think, that array references and ordinary scalars are both scalars. What would be the difference between $a[2] and $a[[2]] anyway? Aren't these just the same? If so, why not grab back into the old box, and get the syntax for "multidimensional hashes" in perl4? single dimension: $hash{$item} 2 dimensions: $hash{$item1, $item2} Note that because of the '$' prefix, this cannot be confused with a narray slice: hash slice, not multidimensionanl hash: @hash {$item1, îtem2} So, the similar syntax for ordinary arrays would then be: $array[2, 3] not $array[[2, 2]] Please feel free to corrct me if I'm wrong. -- Bart.Thread Previous | Thread Next