https://github.com/feeley/gambit/pull/61 - for a quick proof of concept, that's a very neat use of the ffi type!!!
So you tried to somehow use wills to force GC order? Without having studied this, I guess that was not what they were intended for in the first place and it makes good sense that that did not work out well.
Once user code gets hold of A, pure Scheme code can't really know when it's OK to let go of that vector. It's the same problem. Of course you can keep a reference forever, but you don't want to hold on to unneeded memory either.
You should be able to work that out and question is just how heavy it would be implementation-wise to do, no??
If not why not?
But these restrictions need not be showstoppers. A scheme that might work:- on initalization, create an ___alloc_rc'ed table[1] and assign a global C pointer to it- whenever you create a dependent foreign pointer F, store in the table a reference to its dependent object D, keyed by the address of the F's C pointer, and
- set a release function for F that will clear that entry in the table.Why do you need a "table" (by table here you mean resizable vector)?
Nice!Gambit's builtin functionality for this is fully sufficient at Gambit's level of abstraction over the underlying system, and indeed there's plenty of space for higher-level abstractions that more in this area.
So the totality of what you are looking to provide isa) the c-struct form which is analogous to define-type withb) Scheme-like automatic dependency GC-reference handling between c structure instances as discussed here?