[Ecls-list] "Silent" ECL

Christian Svensson info at cmd.nu
Sun Sep 14 16:19:24 UTC 2008


Hello.

Many thanks, that cleared up many things.
Works like a charm, thanks to all of you!

Greetings,

On Sun, Sep 14, 2008 at 5:03 PM, Juan Jose Garcia-Ripoll <
juanjose.garciaripoll at googlemail.com> wrote:

> On Sun, Sep 14, 2008 at 4:25 PM, Christian Svensson <info at cmd.nu> wrote:
> >
> > Earlier in this thread I was told that cl_* is the same as the commands
> in LISP.
> > Therefor I test this both in "ecl" and using si_safe_eval:
> >
> > (let ((*debugger-hook* nil)) (load "test.lisp"))
> >
> > I get thrown to the top-level anyway.
>
> *DEBUGGER-HOOK* may contain a  function for the user to intercept all
> calls to the debugger. Now if you set this to NIL you are telling the
> Common Lisp environment that you do not want to install any debugger
> hook, so the ordinary prompt is activated
>
> Look at the lisp definition fi si::safe-eval
>
> (defun safe-eval (form env err-value)
>  (catch 'si::protect-tag
>    (let* ((*debugger-hook*
>        #'(lambda (condition old-hooks)
>        (throw 'si::protect-tag condition))))
>      (return-from safe-eval (eval-with-env form env))))
>  err-value)
>
> You said that you want to capture the error and learn what happens.
> This can be coded in Common Lisp as follows
>
> (defun my-safe-eval (form env)
>  (handler-case (values (eval-with-env form env) nil)
>    (error (c) (return-from my-safe-eval (values nil c)))))
>
> This function returns two values: the output of your form and an
> optional second value with any error that might get signaled. The main
> value is directly output by the function, while the second value may
> be retrieved using VALUES(1). Beware that the code below was directly
> typed into this email and may have typos, errors, etc, but you
> probably get the general idea.
>
> cl_object aux = c_string_to_object( "(defun my-safe-eval (form env)
>  (handler-case (values (eval-with-env form env) nil)
>    (error (c) (return-from my-safe-eval (values nil c)))))");
>
> cl_object function_name = cl_eval(1, aux);
> cl_object form = c_string_to_object("(LOAD ... ");
> cl_object output = cl_funcall(3, function_name, form, Cnil);
> cl_object error = VALUES(1);
> if (error != Cnil) {
>  ...
> }
>
> Note also that condition objects may be printed with various degrees
> of precision: by default you only get a #<... >, but in pretty print
> form you wil get the full error message.
>
> Juanjo
>
> --
> Instituto de Física Fundamental
> CSIC, Serrano, 113, Madrid 28040 (Spain)
> http://juanjose.garciaripoll.googlepages.com
>



-- 
Christian Svensson
Command Systems
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20080914/5addb5f2/attachment.html>


More information about the ecl-devel mailing list