[Ecls-list] Newbie get/set question

Juan Jose Garcia Ripoll lisp at arrakis.es
Fri Nov 18 02:06:00 UTC 2005


On Fri, 2005-11-18 at 18:57 +1100, David Creelman wrote:
> I can run scripts/functions, but it's not clear to me how I get a
> variable from ECL over to C/C++. There is mention of ffi:, but I don't
> quite get that. Any pointers would be appreciated.

You can

1) Get the output directy from cl_eval() if there is a single lisp
statement.

2) You can, in compiled files, access C variables using FFI. The value
of this C variable can be set to whatever your lisp code wants to
output. I find this, however, overkilling.

3) You can simply define a special variable and assign it the value you
want. To recover this value from C there are multiple possibilities.
Perhaps the simplest (but not the safest one) is to use

	c_string_to_object("thepackage::*thevariable*")

which will read the string and evaluate the symbol *thevariable* from
the package "THEPACKAGE" and return the value. Formerly you might have
done something like

	(in-package :thepackage)

	(setf *thevariable* (+ 1 1))

Have fun,


Juanjo






More information about the ecl-devel mailing list