[Ecls-list] Overriding SI::SIGNAL-SIMPLE-ERROR (si_signal_simple_error) I cannot create handlers for FEprogram_error/FEcontrol_error/FEreader_error

Juan Jose Garcia Ripoll lisp at arrakis.es
Tue Mar 14 08:32:03 UTC 2006


Hi Douglas,

first of all, you should not try redefining universal-error-function. On
a separate post I noted the new way in which si_safe_eval() works. This
function redefines *debugger-hook* and sets it to a function that aborts
on all errors, returning control to the code that invoked the buggy
function or form.

A better way is the one which I described on a previous email to the
list, and which I reproduced below. This is based on using lisp to catch
errors when reading forms, but it can be generalized to evaluation of
forms by replacing read-from-string with eval.

Regards,

Juanjo

const char *handler = "
#.(lambda (string)
    ;;
    ;; Read a lisp object from STRING. The output are two values
    ;;   VALUES(0) = object read or NIL
    ;;   VALUES(1) = NIL or condition due to reader error
    ;;
    (handler-case
        (values (read-from-string string) nil)
      (error (c) (values nil c))))
";

cl_object
my_c_string_to_object(const char *string)
{
    static cl_object string_parser = NULL;

    if (string_parser == NULL) {
       ecl_register_static_root(&string_parser);
       string_parser = c_string_to_object(handler);
    }
    return funcall(2, string_parser, make_simple_string(string));
}






More information about the ecl-devel mailing list