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
https://github.com/euccastro/gambit-ffi-types/blob/master/ffi-types-lib.scm
This approach is beautifully simple and, unlike the one involving wills, seems robust to me.
I also added some usage instructions to the README:
https://github.com/euccastro/gambit-ffi-types
Happy new year!
Afficher les réponses par date