<div dir="ltr"><div>I've finally found a way to manage references between foreign objects (which actually works for any kind of Scheme memory-allocated object) that avoids the problems of using wills.  I keep a mapping from _serial numbers_ of dependent objects to references to the objects they depend upon.  On garbage collection (using the ##add-gc-interrupt-job! hook), I walk this mapping (currently an assoc list) and remove any entries where the serial number can no longer be found in ##serial-number-to-object-table.  So you call it a table with anemic (weaker than weak!) keys.  See<br>
<br><a href="https://github.com/euccastro/gambit-ffi-types/blob/master/ffi-types-lib.scm">https://github.com/euccastro/gambit-ffi-types/blob/master/ffi-types-lib.scm</a><br><br></div><div>This approach is beautifully simple and, unlike the one involving wills, seems robust to me.<br>
<br></div><div>I also added some usage instructions to the README:<br><br><a href="https://github.com/euccastro/gambit-ffi-types">https://github.com/euccastro/gambit-ffi-types</a><br><br></div><div>Happy new year!<br></div>
</div>