<div dir="ltr">On Thu, Sep 11, 2008 at 9:44 PM, Christian Svensson <span dir="ltr"><<a href="mailto:info@cmd.nu">info@cmd.nu</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr"><span style="font-family: courier new,monospace;">  if( type_of( result ) == t_symbol )</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">  {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    printf( "- Loading result: %s\n", cl_symbol_value( result ) );</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">  }</span><br></div></blockquote></div><br>Hi Christian, first of all sorry that programming embedded ECL seems so difficult, but believe me: it is not.<br><br>The key to understand how ECL works is to grasp that it is just a C library providing _all_ of Common Lisp. Hence, to know how to program ECL you cannot avoid learning some Common Lisp, but at the same time if you know Common Lisp you will know how to manipulate data in C without resorting to low level hacks.<br>
<br>Given this, the statements above are wrong. Most functions with prefix cl_ are functions defined in the Common Lisp CL or COMMON-LISP package. In particular cl_symbol_value is the C equivalent of SYMBOL-VALUE which returns the value of a variable<br>
   <a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_5.htm">http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_5.htm</a><br><br>Hence, when your program reaches this point it has read the form<br>
  (DEFUN NO-FUNC ....)<br>and it has evaluated this form which results in an output value<br>  NO-FUNC<br>This is the same as if I type the previous statement in a Common Lisp: the output will be the symbol that names the function I have defined. However, NO-FUNC is not a variable and if you type (SYMBOL-VALUE 'NO-FUNC) in whatever Lisp it will complain.<br>
<br>Unfortunately there is not yet a simple way to protect yourself from mistakes in the C program because there are no simple C constructs to capture errors. There are some macros defined in the ECL C headers but I do not want to recommend them because they are prone to change.<br>
<br>BTW, this other statement is also wrong<br><br><span style="font-family: courier new,monospace;">  result = si_safe_eval( 3, c_string_to_object( "(my-test-function 1)" ), Cnil, OBJNULL );</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">  if( result == OBJNULL )</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  {</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">    printf( "Calling of function failed\n" );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    return 1;</span><br style="font-family: courier new,monospace;">



<span style="font-family: courier new,monospace;">  }</span><br style="font-family: courier new,monospace;"><br>This is because your cl_read() statement only reads 1 form and not the 2nd form which contains the definition for MY-TEST-FUNCTION. You would be better off using cl_load().<br>
<br>Hope this helps you get started,<br><br>Juanjo<br clear="all"><br>-- <br>Instituto de FĂ­sica Fundamental<br>CSIC, Serrano, 113, Madrid 28040 (Spain) <br><a href="http://juanjose.garciaripoll.googlepages.com">http://juanjose.garciaripoll.googlepages.com</a><br>

</div>