Karim BELABAS on Tue, 10 Sep 2002 17:14:11 +0200 (MEST)


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

Re: gnil


On Tue, 10 Sep 2002, Bill Allombert wrote:

> On Tue, Sep 10, 2002 at 03:42:47PM +0200, Karim BELABAS wrote:
> > On Tue, 10 Sep 2002, Bill Allombert wrote:
> > > The magic gnil object is static in GP.
> >
> > No. It is global in the library.
> src/language/init.c read
> /*      Variables statiques communes :         */
> FILE    *pari_outfile, *errfile, *logfile, *infile;
> GEN     *polun, *polx;
> GEN     gnil, gzero, gun, gdeux, ghalf, polvar, gi;
> GEN     gpi=NULL, geuler=NULL, bernzone=NULL;
>
> which lead me to believed it was static.
>
> I suppose we need to fix paricom.h ?
>
> > What's wrong with
> >
> > GEN f(GEN x) { return gcmp0(x)? gnil: gun; }
>
> yellowpig% cat >test.c <<EOF
> #include<pari/pari.h>
> GEN f(GEN x) { return gcmp0(x)? gnil: gun; }
> EOF
> yellowpig% gcc test.c
> test.c: In function `f':
> test.c:2: `gnil' undeclared (first use in this function)
> test.c:2: (Each undeclared identifier is reported only once
> test.c:2: for each function it appears in.)

I forgot I had removed it from the public headers... [ it's declared in anal.h ]

(16:53) vintsy-karim% cat >test.c <<EOF
#include<pari/pari.h>
extern GEN gnil;
GEN f(GEN x) { return gcmp0(x)? gnil: gun; }
main(){}
EOF
(16:53) vintsy-karim% gcc test.c -lpari -lm
(16:53) vintsy-karim%


OK, yet another good reason to write a separate header file declaring "private"
exported symbols (and types), say paripriv.h  [ still the stupid old 8.3 DOS
limit ]

Logic would be that
* paridecl.h contains only functions with documented API [ we'd
guarantee stability there ]

* paripriv.h contains undocumented stuff, for which we guarantee nothing.
pari.h would contain something like

#ifdef PARI_USE_PRIVATE
#  include <paripriv.h>
#endif

So we could
1) remove all the "extern ..." declarations currently scattered everywhere
2) move all undocumented stuff from paridecl.h to paripriv.h [ or document
them immediately ]
3) start documenting things from paripriv.h and move them to paridecl.h

Cheers,

    Karim.

P.S: Not sure whether paripriv.h should be a wrapper including a bunch of
individual header files, or monolithic like paridecl.h.
-- 
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/