Yes, a
is the original mutable, convention will be that this is the placeholder to prevent GC and it should be kept or the object (from C++ in this case) stored in the void pointer will be deleted by the finalizer attached to a
. This is in fact an implementation detail for referencing C++ objects. Since MutableFoo
and ImmutableFoo
are both created using the C API, they have no constructor attached (and I couldn’t find a way to attach one from C) so this hack allows me to convert to the stack-allocated “reference type” without using ccall
.