Dan Sugalski wrote:
> At 07:57 AM 8/11/00 +1000, Jeremy Howard wrote:
> >Dan Sugalski wrote:
> > > Strong typing and sparse arrays are orthogonal--no reason we shouldn't
use
> > > them if someone does:
> > >
> > >    $foo[time]
> > >
> > > or something of the sort. (People like huge arrays with few scalars in
> > > them too... :)
> > >
> >Good point. It also occurs to me that we would want some syntax to say
> >"Don't make this sparse". That way, arrays that are, for example, read
from
> >a file, could be stored contiguously and can be accessed without
traversing
> >extra pointers.
>
> I dunno. If someone tells perl an array's sparse, I'd tend to believe they
> knew what they were doing. Wouldn't hurt to have some sort of debugging
> analysis messages that's notice you declared an array sparse but it really
> wasn't, but...
>
Err... that's what I meant. We need a way to tell Perl whether an array is
sparse or not. I guess they should be non-sparse by default (except for
lists created by lazily evaluated list generation functions, of course).
Then some notation is required to say that "this one is sparse". It would
also be nice (although an optional extra) to say what the 'default' element
value is:

  my @funny_array : sparse(1) = ((1) x 500, 5);

would tell Perl that it shouldn't store the '1's, and just store the indexes
and values of everything else. Of course, the default should be to store
zeros sparely:

  my @unfunny_array : sparse = ((0) x 500, 5);

Would this kind of syntax make sense?

Oops, I shouldn't say "syntax" on the internals list ;-)

What other attributes (other than 'constant') should we consider?


Reply via email to