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

Fill-pointers and sequences

There are two other passages you might consider.  First, page 246, last
paragraph, states that the :start and :end arguments should be integer
indices "into the sequence"; is an index larger than the fill pointer
"into the sequence" or merely "into the vector"?  Second, page 291 notes
that "aref is unusual among the functions that operate on arrays in that
it completely ignores fill pointers".  If we really believed the book to
be careful and accurate, we might infer that other functions not
specifically documented to be in this unusual category may not access
beyond the fill pointer; but in the actual event this inference is shaky
at best.

I think I would be inclined to write the code in this manner:

  (setq a (make-array 10 :fill-pointer 3))

  (let ((old-fill-pointer (shiftf (fill-pointer a) (array-total-size a))))
    (fill a nil :start (fill-pointer a) :end (array-dimension a 0))
    (setf (fill-pointer a) old-fill-pointer))

or, for the truly worried,

  (let ((old-fill-pointer (array-total-size a)))
	(progn (setf (fill-pointer a) (array-total-size a))
	       (fill a nil :start (fill-pointer a) :end (array-dimension a 0)))
      (setf (fill-pointer a) old-fill-pointer)))

I do not feel strongly about which way this issue is resolved, but I
agree that it should be tied down.  I mildly favor a strict interpretation.