From: Robert D. <rob...@gm...> - 2015-09-08 19:48:00
|
On 2015-09-07, David Scherfgen <d.s...@go...> wrote: > the following integral results in an error "quotient by zero": > > integrate(ev(ratsimp(1/(x^(5/2)+3*x^(1/3))),algebraic),x); > > Unfortunately, I can't catch the error using errcatch. It goes right > through it, i.e. the whole evaluation is aborted, and I don't get any > result (usually, errcatch would give me an empty list if it caught an > error). When "quotient by zero" is encountered, 'RAT-ERR is thrown, which blows through 'catch' and 'errcatch'. I believe that's a bug. A solution is to call RAT-ERROR-TO-MERROR in 'catch' and 'errcatch'. I got that from TOPLEVEL-MACSYMA-EVAL. From what I can tell, that makes 'errcatch' work as expected for the above example (i.e., return an empty list) and obviates the need for redefining MERROR. best, Robert Dodier PS. Here is a patch. diff --git a/src/suprv1.lisp b/src/suprv1.lisp index d0c5fa4..be0a59f 100644 --- a/src/suprv1.lisp +++ b/src/suprv1.lisp @@ -770,14 +770,14 @@ (defmspec $errcatch (form) (let ((errcatch (cons bindlist loclist)) ret) (if (null (setq ret (let (*mdebug*) - (errset (mevaln (cdr form)) lisperrprint)))) + (errset (rat-error-to-merror (mevaln (cdr form))) lisperrprint)))) (errlfun1 errcatch)) (cons '(mlist) ret))) (defmspec $catch (form) (let ((mcatch (cons bindlist loclist))) (prog1 - (catch 'mcatch (mevaln (cdr form))) + (catch 'mcatch (rat-error-to-merror (mevaln (cdr form)))) (errlfun1 mcatch)))) (defmfun $throw (exp) |