fill指针会影响GC吗?
Does the fill pointer affect GC?
如果我有这个结构:
(defstruct foo
(x 0 :type 'fixnum))
和这个数组:
(defvar arr (make-array 0 :element-type 'foo :adjustable t :fill-pointer 0))
然后执行以下操作:
(vector-push-extend (make-foo) arr)
(setf (fill-pointer arr) 0)
数组中的 foo
现在是 GC 的候选对象吗?
我从 CLHS 了解到它不是 active,但不确定该状态的含义。
超出填充指针的元素仍然可以访问,并且不会被垃圾回收。打印数组时,不会打印填充指针之外的元素,如果使用 ARRAY-PUSH
,它们将被覆盖(因为它使用填充指针来确定添加新元素的位置),但其他操作数组正常对待它们。
例如,AREF
的规范说:
aref
ignores fill pointers. It is permissible to use aref
to access any array element, whether active or not.
如果我有这个结构:
(defstruct foo
(x 0 :type 'fixnum))
和这个数组:
(defvar arr (make-array 0 :element-type 'foo :adjustable t :fill-pointer 0))
然后执行以下操作:
(vector-push-extend (make-foo) arr)
(setf (fill-pointer arr) 0)
数组中的 foo
现在是 GC 的候选对象吗?
我从 CLHS 了解到它不是 active,但不确定该状态的含义。
超出填充指针的元素仍然可以访问,并且不会被垃圾回收。打印数组时,不会打印填充指针之外的元素,如果使用 ARRAY-PUSH
,它们将被覆盖(因为它使用填充指针来确定添加新元素的位置),但其他操作数组正常对待它们。
例如,AREF
的规范说:
aref
ignores fill pointers. It is permissible to usearef
to access any array element, whether active or not.