Ok, you have the following problems:

1) If you do not start a toplevel there will not be any active restarts.
This is logical: it is your program's responsibility to set them up! So if
you want a function to be able to use ABORT then define an evaluating
function that sets the restart up.

2) You are using cl_eval(...) which does not set up those restarts. ECL
ships with a function, si_safe_eval (ext:safe-eval) which performs
evaluation in a safe way, with a handler for errors that returns a default
value.

3) It is recommended generally to have a catch-all region around your C
code. This sets up a point that protects from unwanted QUIT statements and
sets up a point to jump to in case of stack overflows, memory exhaustion,
etc See http://ecls.sourceforge.net/new-manual/re37.html

4) Instead of c_string_to_object() you might want to use
ecl_read_from_string_safe(s,v) where "v" is the value returned in case of
error condition.

The program, in one possible shape

#include <ecl/ecl.h>

#define READCL(expr) (c_string_to_object(# expr))

int main(int argc, char **argv)
{
       cl_object x;

       cl_boot(1, &argv[0]);

       CL_CATCH_ALL_BEGIN(ecl_process_env()) {

       x = c_string_to_object("(format t \"Hello~%\")");
       cl_print(1,x);
       x = si_safe_eval(3, x, Cnil, Cnil);
       cl_print(1,x);

       // Forces program to halt, reading from stdin
       x = c_string_to_object("(vvvvformat t \"Hello~%\")");
       cl_print(1,x);
       x = si_safe_eval(3, x, Cnil, Cnil);
       cl_print(1,x);

       } CL_CATCH_ALL_END;

       cl_shutdown();
}

The output is fine (notice lack of error messages!)

(FORMAT T "Hello~%") Hello

NIL
(VVVVFORMAT T "Hello~%")
VVVVFORMAT
NIL

-- 
Instituto de FĂ­sica Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Ecls-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to