CL arrays



>>>>> "Robert" == Robert Dodier <robert.dodier at gmail.com> writes:

    Robert> On 1/18/07, Raymond Toy <raymond.toy at ericsson.com> wrote:

    Robert> I think I'd prefer to make Lisp arrays invisible from the user's point
    Robert> of view. I'd like to rework lists and matrices to use arrays for
    Robert> storage, but without exposing the underlying array.
    >> 
    >> I can understand having matrices stored in arrays instead of lists of
    >> lists, but why would you want lists to use arrays for storage?

    Robert> Well, time to access an element is constant (I hope) but time
    Robert> to access a list element depends on the position of the element --
    Robert> it takes longer to get to the elements at the end of the list.
    Robert> The time to get the n-th element might be logarithmic or linear
    Robert> or something else, but for various Lisp implementations that I've
    Robert> looked at, it's not constant. I'm not sure at this point if constant-
    Robert> time access for lists is worth the trouble, but I also don't want to
    Robert> rule it out.

Ok, but then the time to insert an element at the beginning of a list
isn't constant anymore.  

Hmm.  But I see that I don't know the maxima equivalent of Lisp's cons
and/or push, so maybe insertion at the beginning of a list can't be
done in constant time like in Lisp.

Ray