Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the fill pointer affect GC?

If I have this struct:

(defstruct foo
  (x 0 :type 'fixnum))

and this array:

(defvar arr (make-array 0 :element-type 'foo :adjustable t :fill-pointer 0))

and then do the following:

(vector-push-extend (make-foo) arr)
(setf (fill-pointer arr) 0)

Is the foo in the array now a candidate for GC?

I understand from the CLHS that it is not active, but am unsure of the implications of that state.

like image 214
Baggers Avatar asked Jan 16 '16 22:01

Baggers


1 Answers

Elements that are beyond the fill pointer are still accessible, and will not be garbage collected. Elements beyond the fill pointer aren't printed when you print the array, and they'll be overwritten if you use ARRAY-PUSH (since it uses the fill pointer to determine where to add the new element), but other operations on the array treat them normally.

For instance, the specification of AREF says:

aref ignores fill pointers. It is permissible to use aref to access any array element, whether active or not.

like image 165
Barmar Avatar answered Oct 14 '22 12:10

Barmar