<div dir="ltr">Hello again.<br><br>While the error handling works like a charm, I would still like to<br>disable ECLs signal handling - at least for SIGINT and the like.<br><br>Is this possible?<br><br>Greetings,<br><br><div class="gmail_quote">
On Sun, Sep 14, 2008 at 6:19 PM, Christian Svensson <span dir="ltr"><<a href="mailto:info@cmd.nu">info@cmd.nu</a>></span> wrote:<br><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">Hello.<br><br>Many thanks, that cleared up many things.<br>Works like a charm, thanks to all of you!<br><br>Greetings,<div><div></div><div class="Wj3C7c"><br><br><div class="gmail_quote">On Sun, Sep 14, 2008 at 5:03 PM, Juan Jose Garcia-Ripoll <span dir="ltr"><<a href="mailto:juanjose.garciaripoll@googlemail.com" target="_blank">juanjose.garciaripoll@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>On Sun, Sep 14, 2008 at 4:25 PM, Christian Svensson <<a href="mailto:info@cmd.nu" target="_blank">info@cmd.nu</a>> wrote:<br>
><br>
> Earlier in this thread I was told that cl_* is the same as the commands in LISP.<br>
> Therefor I test this both in "ecl" and using si_safe_eval:<br>
><br>
> (let ((*debugger-hook* nil)) (load "test.lisp"))<br>
><br>
> I get thrown to the top-level anyway.<br>
<br>
</div>*DEBUGGER-HOOK* may contain a function for the user to intercept all<br>
calls to the debugger. Now if you set this to NIL you are telling the<br>
Common Lisp environment that you do not want to install any debugger<br>
hook, so the ordinary prompt is activated<br>
<br>
Look at the lisp definition fi si::safe-eval<br>
<br>
(defun safe-eval (form env err-value)<br>
(catch 'si::protect-tag<br>
(let* ((*debugger-hook*<br>
#'(lambda (condition old-hooks)<br>
(throw 'si::protect-tag condition))))<br>
(return-from safe-eval (eval-with-env form env))))<br>
err-value)<br>
<br>
You said that you want to capture the error and learn what happens.<br>
This can be coded in Common Lisp as follows<br>
<br>
(defun my-safe-eval (form env)<br>
(handler-case (values (eval-with-env form env) nil)<br>
(error (c) (return-from my-safe-eval (values nil c)))))<br>
<br>
This function returns two values: the output of your form and an<br>
optional second value with any error that might get signaled. The main<br>
value is directly output by the function, while the second value may<br>
be retrieved using VALUES(1). Beware that the code below was directly<br>
typed into this email and may have typos, errors, etc, but you<br>
probably get the general idea.<br>
<br>
cl_object aux = c_string_to_object( "(defun my-safe-eval (form env)<br>
(handler-case (values (eval-with-env form env) nil)<br>
(error (c) (return-from my-safe-eval (values nil c)))))");<br>
<br>
cl_object function_name = cl_eval(1, aux);<br>
cl_object form = c_string_to_object("(LOAD ... ");<br>
cl_object output = cl_funcall(3, function_name, form, Cnil);<br>
cl_object error = VALUES(1);<br>
if (error != Cnil) {<br>
...<br>
}<br>
<br>
Note also that condition objects may be printed with various degrees<br>
of precision: by default you only get a #<... >, but in pretty print<br>
form you wil get the full error message.<br>
<div><div></div><div><br>
Juanjo<br>
<br>
--<br>
Instituto de Física Fundamental<br>
CSIC, Serrano, 113, Madrid 28040 (Spain)<br>
<a href="http://juanjose.garciaripoll.googlepages.com" target="_blank">http://juanjose.garciaripoll.googlepages.com</a><br>
</div></div></blockquote></div><br><br clear="all"><br></div></div>-- <br>Christian Svensson<br>Command Systems<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br>Christian Svensson<br>Command Systems<br>
</div>