Karim Belabas on Sun, 01 Sep 2013 10:52:00 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: pari_err(): callback function instead of longjmp()


* Jeroen Demeyer [2013-09-01 10:22]:
> On 2013-09-01 10:17, Bill Allombert wrote:
> >This is already the case, see the documentation of
> >cb_pari_handle_exception().
> I know about that function, but that's a callback *after* printing
> the error message. I am talking about a callback *before*.

Hum. The documentation does not specify exactly when that callback is
triggered but the current understanding (expection or SIGINT) is to

0) build a t_ERROR object ( to be returned by pari_err_last() )
1) return if we are catching errors ( within pari_CATCH / pari_ENDCATCH blocks )
2) flush stdout / stderr
3) print \n if needed, e.g. after print1()
4) notify: "error..." (+ call stack trace) or "user interrupt"
5) call cb_pari_handle_exception
6) restore PARI to a sane state (err_recover)
7) exit ( default cb_pari_err_recover is pari_exit() )

Since pari_err_last() allows to inspect (and use!) the t_ERROR object
containing everything we know about the error context, it is possible to
have step 5) occur before 4): the callback would print the message itself
if needed. But the current behaviour is more convenient if we want to
let PARI print that message.

Another "raw" callback that would be triggered between 1) and 2) ?
Say, cb_pari_prehandle_exception ?

Cheers,

    K.B.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux1.fr/~kbelabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]
`