Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Juan Jose Garcia-Ripoll <juanjose.garciaripoll-gM/Ye1E23mwN+BqQ9rBEUg <at> public.gmane.org>
Subject: Re: "Silent" ECL
Newsgroups: gmane.lisp.ecl.general
Date: Sunday 14th September 2008 15:03:29 UTC (over 8 years ago)
On Sun, Sep 14, 2008 at 4:25 PM, Christian Svensson  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
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ecls-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ecls-list
 
CD: 3ms