<div dir="ltr">The following question was raised during my development of an <a href="https://github.com/lokedhs/cl-rabbit-async">asynchronous library</a> I'm currently building for RabbitMQ.<div><br></div><div>In summary, the library allows you to create an object of type <font face="monospace, monospace">ASYNCH-CONNECTION</font>, from which instances of <font face="monospace, monospace">ASYNC-CHANNEL</font> can be retrieved. A connection holds a reference to all channels that it uses, and each channel holds a reference to its connection. The connection object has a pointer to a native CFFI object that for the underlying connection (my library is built on the RabbitMQ C API).</div><div><br></div><div>My question is: Should I use trivial-garbage to create a GC hook for the connection object so that if the user of the library forgets to close the connection, it will get closed eventually once it's GC'ed?</div><div><br></div><div>I can see arguments for both behaviours:</div><div><ul><li>It's a bad idea, since losing the reference to the connection object means that the program is broken, and silently cleaning up the underlying connection might hide the fact there is a bug (if the GC doesn't run often enough I might have hundreds or even thousands of lingering connections)</li><li>On the other hand, it might be a good idea since Lisp developers often use the REPL to experiment, so it's easy to accidentally lose a reference to an object during testing. Thus, using the GC hook will improve the stability of one's development environment.</li></ul><div>To me, there is no strictly correct answer to the question, which is why I'm asking for suggestions from you guys.</div></div><div><br></div><div>Regards,</div><div>Elias (loke on #lisp)</div></div>