[Ecls-list] "Silent" ECL

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Fri Sep 12 19:55:02 UTC 2008


On Thu, Sep 11, 2008 at 9:44 PM, Christian Svensson <info at cmd.nu> wrote:

>   if( type_of( result ) == t_symbol )
>   {
>     printf( "- Loading result: %s\n", cl_symbol_value( result ) );
>   }
>

Hi Christian, first of all sorry that programming embedded ECL seems so
difficult, but believe me: it is not.

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.

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
   http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_5.htm

Hence, when your program reaches this point it has read the form
  (DEFUN NO-FUNC ....)
and it has evaluated this form which results in an output value
  NO-FUNC
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.

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.

BTW, this other statement is also wrong

  result = si_safe_eval( 3, c_string_to_object( "(my-test-function 1)" ),
Cnil, OBJNULL );
  if( result == OBJNULL )
  {
    printf( "Calling of function failed\n" );
    return 1;
  }

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().

Hope this helps you get started,

Juanjo

-- 
Instituto de Física Fundamental
CSIC, Serrano, 113, Madrid 28040 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20080912/cce808d6/attachment.html>


More information about the ecl-devel mailing list