Re:On the impossibility of composing finalizers and FFI
by irq-1 on Tuesday February 27, 2024 @02:50PM
(#39528844)
LuaJIT lets you remove a finalizer:
> An existing finalizer can be removed by setting a nil finalizer, e.g. right before explicitly deleting a resource:
ffi.C.free(ffi.gc(p, nil)) -- Manually free the memory.
https://luajit.org/ext_ffi_api.html#ffi_gc
> or attempt to manually extend the lifetime of a finalizable object, and then pray the compiler and GC don’t learn new tricks to invalidate your trick.
This is also silly. There is no reason whatsoever that a GC can’t offer an actual API to keep an object alive.