[cffi-devel] Re: unnamed callback (closures?)

Jan Rychter jan at rychter.com
Tue Feb 7 08:51:19 UTC 2006


>>>>> "James" == James Bielman <jamesjb at jamesjb.com> writes:
 James> Jan Rychter <jan at rychter.com> writes:
 >>>>>>> "Luís" == Luís Oliveira <luismbo at gmail.com> writes:
 >> Luís> I'm pretty sure we could support anonymous callbacks, on SBCL
 >> Luís> and CLISP anyway. Do any other Lisps support this?

 >> So, perhaps it is worth implementing as an optional
 >> feature. Hopefully other implementations will follow suit.

 James> I took a shot at implementing this on SBCL and CLISP (I don't
 James> have a working ECL installation), here's the patch:

 James> This still needs unit tests but cursory testing from the REPL
 James> looks good---please give it a try.

It works for me in SBCL. Neat, thanks!

However, I'm puzzled as to why you decided not to name the callback and
remember it. Is there really no way to release the memory occupied by
the trampoline code and let the closure be GCd when it's no longer
needed?

In my case, this is going to be a problem. If you generate a bunch of
callback-lambdas for each context menu appearance, you will soon end up
with lots of them in memory. If there really is no way to release them,
I'll probably have to think of a different approach (with dispatching
functions, I guess, as Martin suggested).

--J.



More information about the cffi-devel mailing list