I'm busy writing a partial binding (not at all ready for any sort of release, I blame my thesis) of the OpenCV library. To integrate garbage collection, I've wrapped key foreign objects with clos objects and attached a finalizer to the clos wrappers. Now, the problem is that sometimes, if you use the foreign pointer associated with the wrapper, the wrapper itself becomes no longer needed and a smart compiler might decide to make it available for garbage collection. Eg.
Code: Select all
(let ((foreign-object foo))
(foreign-function (foreign-pointer foreign-object)))
Is there any portable way I could prevent this? I know settings (safety 3) is supposed to stop this in SBCL, but am unsure whether this is true across implementations. Any other solution would be nice also.
Thanks
