Karim BELABAS on Thu, 12 Sep 2002 00:36:03 +0200 (MEST)

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

Re: error recovery (was Re: gp: series bug)

On Wed, 11 Sep 2002, Ilya Zakharevich wrote:
> On Wed, Sep 11, 2002 at 04:56:14AM +0200, Karim BELABAS wrote:
>> The error recovery code in libpari is experimental (hence not documented),
>> and I've just modified it in CVS a few hours ago, while investigating some of
>> Igor's bug reports [ funny you'd ask just now! ].
>> I wanted to encapsulate all the code in the library using (something looking
>> like) the trap() mechanism. So I defined a set of 3 macros CATCH / TRY /
>> ENDCATCH to hide more complicated routines.
> Please do not.  trap() is not a mechanism good enough to have it in
> two places.  E.g.:
> >   CATCH(numerr) {
> I do not think the situation with one trap to catch is frequent enough
> to make this interface useful.

Please elaborate. I'm note sure I understand your point. You'd rather have a
general CATCH(CATCH_ALL), and no specific error number ?

Well, if I only want to catch "precision error in truncation", I'd rather have

  CATCH(precer) { ...; }


    switch (pari_errno) {
      case precer: ...; break;
      default: THROW(pari_errno);

and have to propagate everything I get and don't like. I don't see any point
in complicating the interface, granted that both forms are available at
essentially no extra cost.

It already occurs naturally 6 times in the library (+ 1 to define trap()).
In most cases we want to catch a specific error ( Exception: gegal and the
pipe testing code ).

What _is_ true is that most error numbers are useless.

> Typically, one will want to perform cleanups manually is needed to (to
> simplify propagation of the trap to wrappers in another
> exception-conscious language).
> > Note: I could provide another macro, says CATCH_RELEASE(), that you could
> > invoke if you insist on getting out [ and would execute the ENDCATCH cleanup
> > code ]. It is not needed in pari and I don't think I want it.
> So please do.
> >   CATCH(-1)

OK, I've added CATCH_RELEASE() and used CATCH_ALL instead of hardocding
negative integers. In fact CATCH_RELEASE() simplifies some code.

> >   {
> >     switch (pari_errno)
> >     {
> >       case primer1: ...
> I think this is more useful than the specialized interface above...

I don't. I think both are useful (the latter is not yet useful anywhere in
the library for instance).

In any case, I've also included it.

Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathematiques, Bat. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas/
PARI/GP Home Page: http://www.parigp-home.de/