On Sat, Dec 8, 2012 at 8:46 AM, Peter Keller <span dir="ltr"><<a href="mailto:psilord@cs.wisc.edu" target="_blank">psilord@cs.wisc.edu</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

I'm about to use ECL for some embedding work, namely having a front<br>
end C interface to a well-known C plugin system with an ECL backend<br>
implementing all of the plugin functionality.<br></blockquote><div><br></div><div>Good! Please report both success and any problems you may find.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

I have a few questions before I begin:<br>
<br>
1. Is the API denoted in ecl/externals.h pretty stable? Do people think<br>
it is going to change much in the future?<br></blockquote><div><br></div><div>Pretty much stable for all prefixed names (ecl_, cl_, si_). Not prefixed names will get prefixed in a near future, with a compilation flag allowing to use the old names.</div>

<div><br></div><div>But try to stay away from non-standard Common Lisp functions, just in case.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

2. Are there any issues or special considerations with creating CLOS<br>
objects and then calling methods on them from the C side? Will those<br>
methods dispatch correctly on the arguments without additional poking<br>
from the C side?<br></blockquote><div><br></div><div>I do not understand your concerns here. Function calls using a symbol name work the same in the interpreted and compiled world, and in the compiled world we use the same code that you will use in C.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">3. I have a situation where I have C structures full of data and want<br>


to push them into/bring them out of the Lisp side. Are things like<br>
si_make_structure what I'm supposed to use on the C side? Are there<br>
idioms I should know about to perform this type of data translation?<br></blockquote><div><br></div><div>NO! Please learn to use foreign function interfaces, either the ones supplied by ECL, <a href="http://ecls.sourceforge.net/new-manual/">http://ecls.sourceforge.net/new-manual/</a> or some other one, such as CFFI.</div>

<div><br></div><div>Note that it is definitely easier to write C code embedded in lisp code than try to reproduce all functionality of lisp in your plugin, which is why you should consider using ECL to compile your code.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">4. I will have a couple of C files and a pile of lisp files when I'm<br>


done. I assume that I'd just compile and assemble them into a shared<br>
library as denoted elsewhere in the docs and on this list? Are the ecl<br>
non-private functions and symbols minimized in the exports of the<br>
library to lessen the chances of stomping on something in the<br>
application when the plugin gets loaded?<br></blockquote><div><br></div><div>Lisp files only export an init function with a very ugly name and whatever function name that you declare it to export (there is some obscure declaration for that, but right now I do not remember which one).</div>

<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">5. If I si_safe_eval something like (setf a 3), then later si_safe_eval<br>


on the variable a, is that defined? Are toplevel bindings of specials,<br>
functions, macros, persistent between invocations to si_safe_eval?</blockquote><div><br></div><div>This question is not related to the evaluation, but to Common Lisp environments. Each thread has its own environment, plus there is a global environment that encompasses all of them. When you evaluate code in a thread, it affects both of those environments.</div>

<div><br></div><div>* If there was a global variable binding around your evaluated form and you assign to that variable, then the change stays local</div><div><br></div><div>* If there was a thread-local binding, then the change affects only that thread</div>

<div><br></div><div>* Otherwise the change affects the global environment.</div><div><br></div><div>Really, there is nothing different in embedding ECL from running normal lisp code. Please use this for reasoning about how things work: your standard ECL interpreter is just a stupid embedding of ECL in a four lines program!</div>

<div><br></div><div>Juanjo</div></div><div><br></div>-- <br>Instituto de Física Fundamental, CSIC<br>c/ Serrano, 113b, Madrid 28006 (Spain) <br><a href="http://juanjose.garciaripoll.googlepages.com" target="_blank">http://juanjose.garciaripoll.googlepages.com</a><br>


</div>