Bill Allombert on Sun, 23 Sep 2012 18:32:11 +0200

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

error/rethrow under GP

Dear PARI developers,

We have documented the libpari interface for error trapping and we have
added support for iferr and iferrname to GP2C.

There are several points:
1) In GP it is possible to raise an error using error(). The error will have a
type 'e_USER', but otherwise is totally freeform. This means it can be difficult
to check if the e_USER error you caught was the one you expected.
Maybe we could try to add the name of the GP function which caused the error
to the t_ERROR object automatically, this is not easy due to anonymous function.

2) Currently error() is used both to raise an error an to rethrow a t_ERROR.
It could be cleaner to provide a separate function rethrow().

3) We could provide a function whileerr(code,E,rec) which is identical to
iferr except that it reevaluate code after an error until it suceed.

4) It is not clear that iferrname() provides enough granularity to be useful,
so we are considering whether iferr() should take an extra predicate instead
and rethrow the error if the predicate is false.

iferr(ellmul(E,P,N),E,errname(E)=="e_INV" && type(component(E,2))=="t_INTMOD",return(gcd(component(E,2),N)))