[Ecls-list] Embedding ECL in a C++ app.
Ivan Toshkov
ivan at toshkov.org
Thu Feb 2 04:54:03 UTC 2006
Hi all,
I've decided to try and embed ECL in a C++ web-app (read CGI scripts)
running under Linux. It is a proprietary application, so I can't post
code here, but probably I can give enough info. We have other
embedded languages, mainly for UI stuff, but I wanted to see how far I
can go with Lisp in this particular setup.
I've tried several times before, but our system failed to compile with
so many errors, that I've got discouraged after an hour or so. Until
the next time. And the most interesting part was, that I had no
problems compiling a sample C++ app with ECL.
At last, a few days ago a colleague of mine actually found the
problem: ECL and our system both had the same file named "config.h".
They both were in the include path, but ours was first, so ECL found
it and, naturally, failed to compile.
So, my first suggestion is to move most of the include files in a
subdirectory, named e.g. "ecl" and include them like this:
#include <ecl/config.h>
The "ecl.h" file itself probably doesn't need to go there, which
should keep it backwards compatible.
BTW, I found that at cl_defvar and cl_defparameter are declared in the
external.h but are never defined. Should be easy to remove them, but
probably better to implement?
Anyway, I managed to run a small script, embedded in the system, so
here are some of my questions:
1. How to catch errors in the C++ part? I use si_safe_eval to run
the Lisp code. When there is an error in it, the Lisp debugger runs.
In a while, I'd probably try to have a REPL, listening on a different
port, but for now (and for the production system), I'd like to just
log the error.
2. The C++ app doesn't use a garbage collector, but I don't know what
happens when I link it with ECL, and through that, with Boehm's GC.
Any pointers (pun unintended, but noticed)?
3. I don't want to complicate the build process more than it's
absolutely necessary, so I don't use the fancy Lisp like C++ macros
@(defun ...) and friends, but I still want to define Lisp functions
with &optional, &keyword, and &rest argument lists from C. How?
Well, that will do for now :)
Cheers,
Ivan
--
All languages are equal,
but Lisp is more equal than others.
More information about the ecl-devel
mailing list