Exposing closures to foreign languages via a DLL
I have an application where multiple threads may be making interleaved calls to a LispWorks-built DLL.Essentially, I would like to do something like:
(let ((configuration-options nil)
(results nil))
(lambda (x) (pushnew x configuration-options))
(lambda (x) (... do some calcs base on current configuration options storing results...))
(lambda (x) (elt results x))
(lambda () (.. clean-up ..)))
Is this a good pattern for Common Lisp as a DLL? Is the way to accomplish this to (fli:define-foreign-callable ...) in the let and then return all of the (fli:make-pointer ...) via a c-structure of function pointers? I'm not having great luck so I'll read up on the FLI some more, but I'm not sure this is the best approach.
If so, is there a way to clean up per closure?