Karim BELABAS on Tue, 26 Nov 2002 14:55:33 +0100 (MET)

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

Re: Patch for install: allow to change prototype

On Fri, 22 Nov 2002 Ilya Zakharevich wrote:
> On Fri, Nov 22, 2002 at 10:18:08PM +0100, Bill Allombert wrote:
>>> So isn't it enough to convert the warning to an error?
>> That was a bad idea. It is a warning, because sometime you put install
>> commands at the start of a GP script. If it was an error, you would not
>> be able to reload the script a second time after having made some
>> modifications.
> Of course one could (using trap()).
> So the question is not of power, but of convenience.
> BTW, I see no reason to have the warning at all.  How is it different from
>  ? f() = 12
>  ? f() = 12

I don't know how to safely "reload" a symbol from an external library. In
particular, you cannot recompile an external module, and re-install a
routine. You can kill() its GP wrapper, then formally re-install it, but
unless dlclose() is called first, you install the old version (still loaded
in memory).

I see two reasons one might want to re-install a routine:

A) the module is recompiled [ don't know how to handle this safely, unless a
reference count tells us dlclose() can be called. But if not? I can save the
install() history, close then reload needed symbols, but this gets awkward. ]

B) fix a prototype [ currently "easily" done with kill() ]

I think the most user-friendly solution is to

1) have a genuine error if we try to use a predefined name, e.g
install(sin,G), or use a name with wrong valence, e.g x = 1; install(x,G)

2) output a clearer Warning (since case A is not treated "properly")

3) update prototype in GP wrapper in any case.

I've committed a patch resulting in the following behaviour:

(14:43) gp > install(addii,GG)  \\ first time: OK
(14:43) gp > install(addii,GG)
  ***   Warning: [install] updating 'addii' prototype; module not reloaded.
(14:43) gp > install(sin,G)
  ***   [install] identifier 'sin' already in use.

Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 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/