From: Nikodemus S. <nik...@ra...> - 2007-09-19 11:17:41
|
On 9/18/07, Bruno Daniel <bru...@gm...> wrote: > I thought it over and now I understand why this function is undocumented: > Using closures as callbacks will result in a serious memory leak: Since the > C code might have stored the function pointer anywhere, Lisp will never be > able to garbage collect the closure. Quite so. Constructing the callback for a closure is also horrendously expensive compared to non-closures: (defun foo (x) (alien-lambda () ... x ...)) (defun bar () (alien-lambda () ...)) FOO needs to round-trip through the compiler every time, whereas BAR does that only on the first call. ...but the reason for this being undocumented is just a feature of me having run out of steam & time while working on this. > I must find another solution for my application. Most C libraries using callbacks have a separate "data" argument to the callback you can use. Cheers, -- Nikodemus |