develooper Front page | perl.perl6.language | Postings from January 2003

Re: More Array Behaviors (Take 2)

From:
Dan Sugalski
Date:
January 28, 2003 10:21
Subject:
Re: More Array Behaviors (Take 2)
Message ID:
a05200f2bba5c79ac32e0@[192.168.2.1]
At 10:13 AM -0800 1/28/03, Michael Lazzaro wrote:
>OK, here are the answers so far -- or more accurately, strawman 
>interpretations of those answers that should be objected to if 
>they're wrong.

I think some of this is incorrect which, because Damian thinks 
otherwise, will need some hashing out from Larry on how he wants perl 
arrays to behave. Because...

>1) Edge cases in array indexing:
>
>     my int @a = (1,2,3);
>
>     @a[3]         # undef      (warning: index out-of-bounds)

Or a real 0, since you said @a can only return integers.

>     @a[2**128]    # EXCEPTION: index is above max allowed index

Except we can manage this internally, so I don't know that it's a problem

>     @a[ Inf ]     # undef      (warning: can't use Inf as array index)

I'd throw an exception here.

>     @a[-4]        # undef   (warning: index out-of-bounds)
>     @a[-Inf]      # undef   (warning: can't use Inf as array index)

Or zero, since it's an int array.

>2) There is a platform-dependent maximum array size, ((2**32)-1 for 
>32-bit platforms.)  Attempting to access an index outside that range 
>throws an exception.  Note that this applies to both 'real' and 
>'sparse' arrays.

But since we've got big(int|float|rat)s there's no real reason for 
that to be a problem. If you want to use 10**100**100 as an array 
index, you could just throw an awful lot of memory at us...
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About