Bill Allombert on Fri, 03 Feb 2012 20:38:53 +0100

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

C interface to t_ERROR and GP2C

Dear PARI developers,

We need to define the C interface to catch PARI errors
(and eventually also the C++ interface).

In particular, I need to add support for iferr and iferrname to GP2C.
Probably it is better to generate code that use CATCH/TRY directly instead of
using a wrapper due to the limitation of wrappers.

Please see a tentative gp2c-like conversion of the ecm function in ??iferrname in
attachement [ecm.c]

But maybe we want to take the opportunuity to rename/tweak.

Finally I wonder if we should not add a new universal object gen_STACK (mkerr(e_STACK)).
The problem is, when the stack overflow , it is not safe to do mkerr(e_STACK),
so if we could return an universal object, this would allow us to remove lot
of special-casing code.

#include <pari/pari.h>

GP; install("ecm","GDGD100,L,p",,"./");

ecm(GEN N, GEN B, long t, long prec)
  if (!B)
    B = mpfact(1000);
    long a;
    for(a = 1; a <= t; ++a)
        GEN E = global_err_data;
        return ggcd(lift(compo(E, 1)), N);
      } TRY {
        powell(initell(gmul(mkvec2s(a,1), gmodulsg(1, N)), prec), 
            gmul(mkvec2s(0,1), gmodulsg(1, N)), B);
      } ENDCATCH;
  return gnil;