EQL (ECL + Qt) in Slime: how it works
2014-12-11 18:11:59 GMT
Hi, this might be of common interest for ECL users, so please see attached file if you want to know more. Cheers, Paul
EQL (ECL + Qt) in Slime -- how does it work?
Start swank using the EQL executable, running the swank server in an ECL thread, and using the main thread for the Qt main event loop.
Wrap every internal EQL function in a macro, which will call the function either directly (if called from GUI/main thread), or, if called from another ECL thread, will wrap the function call in a closure.
This closure will be passed to a queued, blocking Qt function running in the GUI thread, which will in turn call the closure.
The crucial part is passing a Lisp closure from an ECL thread to Qt and calling it from C++ in the GUI/main thread.
This is trivial in ECL/Qt, since both ECL and Qt use/wrap native C threads, and Qt offers a nice utility with Q_INVOKABLE.
First let's wrap the actual Lisp function, e.g. (foo x y) in a closure, so we only need to pass one ECL closure pointer to C++.
No need to pass Lisp arguments to C++, they are in the closure; no return value needed from C++, Lisp return values will be assigned in the closure:(Continue reading)