Karim BELABAS on Thu, 2 Nov 2000 19:14:34 +0100 (MET)


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

Re: [PARI]


[Bill:]
> I use the following easy trick:
> 
> I create a file 'r' with the install commands and other initialization
> steps. When I finish recompiling, I do 
> \q
> gp
> \rr
> 
> to restart a fresh session.

I use a slightly more elaborate trick:

1) You can quit with <C-D> saving 1 keypress...
2) You can also use an alias that repeatedly calls a new gp as the old one is
killed, so 'gp' is useless as well [I use GP in a special purpose window
anyway, and kill the window when I really want to get rid of it].
3) And of course, the \rr part is also useless, since you can easily setup a
file that's read on startup from your gprc automagically [ possibly checking
first whether it's there or not  via trap(,"",read(myfile)) ].

So all the above can be abbreviated to <C-D>, after a few trivial (generic)
setup efforts.


Another useful trick: on startup, my gprc loads, among others:

  tmp_file(n) = Str("$TMPDIR/gp.tmp"n, 1)
  rtmp(n) = read(tmp_file(n))
  wtmp(x, n) =
  { local(file); file = tmp_file(n);
    system("rm -f " file);
    write(file, x)
  }

I use this to "export" GP variables from one session to another. Example:

  ? wtmp(bnf)

in one session, and in the other

  ? bnf = rtmp(); \\ or rtmp;  ugly, but saves two keypress...

I use the default tmp_file(0) as temporary storage, the other ones are
available in case I need to preserve a result, e.g

  ? wtmp(bnf,"K");

and

  ? bnf = rtmp("K");

(which I'll be able to use for a few days before I choose again the "K"
suffix by mistake...)

[I have analogous trivial statements for gdb to export PARI objects as GP
objects while I'm debugging library programs, so that I can use/check them in
a GP session. Or conversely for the debugger to load a GP object created
somewhere else and use it as a GEN in the C program.]

Unfortunately, this only works for variables, I sometimes wish that ? (as an
operator) would return the help string, so as to be able to

  wtmp(?my_function)

for instance. But in that case a general save_session/load_session mechanism
would be preferable [it's in the TODO list].

Cheers,

    Karim.
-- 
Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
--
PARI/GP Home Page: http://www.parigp-home.de/