|Bill Allombert on Wed, 17 Sep 2014 17:02:32 +0200|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|Re: Detecting whether PARI has been initialized|
On Wed, Sep 17, 2014 at 03:51:20PM +0200, Jeroen Demeyer wrote: > On 2014-09-17 15:43, Bill Allombert wrote: > >On Wed, Sep 17, 2014 at 02:09:24PM +0200, Jeroen Demeyer wrote: > >>Dear pari-dev, > >> > >>what is the recommended way to detect whether or not pari_init() has > >>already been called? This is useful for libraries which might > >>interact which other libraries which have initialized PARI. > > > >I would say it is not recommended. > Are you saying that this is a useless feature request? Imagine one > application linking to several libraries which all use PARI. How > would you solve the problem that all those libraries try to call > pari_init()? I am not saying this is useless, but this is dangerous. The issue is that the PARI API is stateful: Calling PARI functions can change PARI state and affect further operations. pari_init/pari_close provide a way to start from a clean slate. Thus if an application is linked to several libraries which all use PARI, the libraries need to cooperate together to avoid walking on each other toes. So having libraries attempting to call pari_init by themselves in a first come/first served basis is not recommended. It is much safer for the libraries to let the user do pari_init/pari_close and try not to alter PARI state unnecessarily. Unless of course libraries encapsulate their PARI calls in a pari_init/pari_close pair, in which case everything is safe as long as they are not nested. Cheers, Bill.