(rontolisp) docs
← cl Package Functions

vector-push-extend

(vector-push-extend value vector &optional extension)

Like vector-push, but when the vector is full it grows the backing storage instead of returning nil, so the push always succeeds and the new index is returned. Any vector with a fill pointer can be grown, whether or not it was created :adjustable (matching common practice; adjustable-array-p reports the flag verbatim). A vector without a fill pointer signals a type-error (fill-pointer).

extension is the number of elements to grow by, added to the capacity verbatim. Without it the capacity DOUBLES (a zero-capacity vector grows to 1), so a push loop stays linear in the number of pushes. The new capacity is the same on every backend and is observable through array-dimension.

A growth opens the slots between the pushed element and the new capacity. They are below the array dimension, so aref may read them, and they hold the vector's element type's own zero -- the same fill make-array gives an unsupplied element: #\Space for a character vector, 0 or 0.0 for a declared integer width or float type, nil for element type t.