[Ecls-list] compile package dependencies to C

Matthew Mondor mm_lists at pulsar-zone.net
Thu Mar 7 19:05:57 UTC 2013


On Thu, 7 Mar 2013 13:26:22 -0500
Sam Sam <gamgee202 at hotmail.com> wrote:

> Now, about the name mangling - is there any way to control it? For example, i had a (defun main ...
> which
>  got renamed to L1main(). Not so bad yet, but the top-level LISP code 
> gets wrapped in a function with a completely random and unpredictable 
> name like _eclpXiVf4X4_TkyRds01(cl_object flag). 

ECL makes sure to create unique C symbols to avoid clashes, but it also
creates CL-side symbols pointing to them.  Your C code can query those
symbols.  If using CLINES, then there is even some syntactic sugar
provided by the ECL C preprocessor, and C-INLINE can be told that an
argument is of type FUNCTION.  Also, cl_funcall() accepts a function
object (which could have previously been obtained using
cl_symbol_function()) or a symbol object directly, just like CL FUNCALL
accepts a function designator.

Examples:

CLINES:

{
	cl_object res;

	res = cl_funcall(1, @symbol);
	/* ... */
}

otherwise (untested, I hope I got this right):

{
	cl_object sym, fun, res;

	sym = cl_make_symbol(cl_string("MAIN"));
	res = cl_funcall(1, sym);

	/*
	 * Cache function object to avoid constant symbol lookup,
	 * useful if calling the function very frequently, but problematic
	 * if the function is redefined in CL, so beware for interactive
	 * development.
	 */
	fun = cl_symbol_function(sym);

	res = cl_funcall(1, fun);
}

-- 
Matt




More information about the ecl-devel mailing list