At 12:10 AM 8/12/00 +1000, Jeremy Howard wrote:
>Dan Sugalski wrote:
> > 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.
:sparse? :)
>I guess they should be non-sparse by default (except for
>lists created by lazily evaluated list generation functions, of course).
The optimizer could also determine if an array should be sparse. If it sees
something it knows is reasonably insane it can tag an array as sparse
internally.
>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?
Yup, sort of, though I'd make undef the default.
>What other attributes (other than 'constant') should we consider?
Sparse type, perhaps, or estimated used/max ratio. Might make the
difference between using, say, B-Tree sparse arrays vs a hash with numeric
indices.
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk