On Thu, 7 Mar 2013 13:26:22 -0500
Sam Sam <gamgee...@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

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to