[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

adjust-array with :initial-elements and fill pointers

    Date: Fri, 22 Nov 85 11:55 EST
    From: Kent M Pitman <KMP@SCRC-STONY-BROOK.ARPA>


      (setq a (make-array 5 :fill-pointer 3))
      (setf (aref a 0) 'x)
      (setf (aref a 2) 'z)
      (adjust-array a 7 :initial-element 'b)

    Which of the following are you proposing:

      1.  A = [ X ? Z ? ? B B ]
      2.  A = [ X ? Z B B B B ]
      3.  A = [ X B Z B B B B ]
      4.  A = [ B B B B B B B ]
      5.  Other (please specify)

I am assuming that "in the bounds" means "less than 5".  Therefore, I am
advocating choice number 1.  See the definition of :initial-element on
page 297.

    CLtL doesn't seem to say what happens to the fill pointer if there was no fill 
    pointer specified in the ADJUST-ARRAY call but there was one specified to 
    MAKE-ARRAY. I assume the implication is that the fill pointer remains 3. (GLS 
    or Scott should correct me if I'm wrong). DLW, I am not clear on whether you 
    are suggesting that it it be reset (ie, that it be the same as specifying 
    :FILL-POINTER NIL or :FILL-POINTER T). Can you elaborate?

I am also assuming that the fill pointer remains 3.

    I would be curious to hear an elaboration of your motivation.

The feeling is that the programmer would reasonably expect this code to
initialize the elements beyond the fill pointer, so that when the fill
pointer is increased, instead of finding unpredictable junk in the
array, the contents will be what was specified by :initial-elements.  It
seems like the most useful definition.