Right way to mix things through FLI
Hi
I am writing application wich have to use C/C++ objects much. I wonder how
to organize C/C++ code for mixin Lisp and C/C++ calls in most elegant way,
especially for passing collections (like list) from internal C/C++ loops to Lisp. For
example, I have time critical C procedure which scans image and searches
conforming pair of points between two images, it puts pair in C++ linked
list when next pair is found. Of course I can pass Lisp function as
callback, but would it be effective to call that function many many times ?
I could also convert resulting C/C++ list to Lisp list, but then unnecessary
list memory issues are possible. The third solution is to incorporate
foreign list through FFI and walk on it's contents by (ffi:dereference...)
and so on. I can also use GC finalizers to free C/C++ objects when I do not
need them.
As Lisp performance is not enough for some tasks (LispWorks 4.3, WinXP).
There should be some way to do such things in right natural way.
I can do with my C/C++ libraries anything to adapt them to Lisp. What should
I do with code without much confrontation with C/C++ memory
allocation/deallocation issues and pass an results of fast internal loops in
most elegant way ?
Thanks in advance
Lisper
I am writing application wich have to use C/C++ objects much. I wonder how
to organize C/C++ code for mixin Lisp and C/C++ calls in most elegant way,
especially for passing collections (like list) from internal C/C++ loops to Lisp. For
example, I have time critical C procedure which scans image and searches
conforming pair of points between two images, it puts pair in C++ linked
list when next pair is found. Of course I can pass Lisp function as
callback, but would it be effective to call that function many many times ?
I could also convert resulting C/C++ list to Lisp list, but then unnecessary
list memory issues are possible. The third solution is to incorporate
foreign list through FFI and walk on it's contents by (ffi:dereference...)
and so on. I can also use GC finalizers to free C/C++ objects when I do not
need them.
As Lisp performance is not enough for some tasks (LispWorks 4.3, WinXP).
There should be some way to do such things in right natural way.
I can do with my C/C++ libraries anything to adapt them to Lisp. What should
I do with code without much confrontation with C/C++ memory
allocation/deallocation issues and pass an results of fast internal loops in
most elegant way ?
Thanks in advance
Lisper