From murdoch.duncan at gmail.com  Mon May  4 01:48:07 2015
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Sun, 03 May 2015 19:48:07 -0400
Subject: [Rd] C-API: check whether R has been initialized ?
In-Reply-To: <CA+JCgN3VW3qe+dDMyfSRJEAUdv-kjjG--HHwwbZk5isH8=oVAQ@mail.gmail.com>
References: <CA+JCgN12YVXnWggr1PTfp81U6Bg3=4ARatOdfNh8wZXM_Aes8g@mail.gmail.com>	<55469D5B.5030701@gmail.com>
	<CA+JCgN3VW3qe+dDMyfSRJEAUdv-kjjG--HHwwbZk5isH8=oVAQ@mail.gmail.com>
Message-ID: <5546B3B7.4010407@gmail.com>

On 03/05/2015 7:02 PM, Laurent Gautier wrote:
> Beside the possible argumentation that with an API elegance and
> convenience might sometimes be superior to necessity, the suggested
> pattern ("every program, including R itself, keeping its own flag") does
> no work too well when the nested embedding of R is involved.
> 
> A concrete example is:
> ```
> $ R -q
>> library('rPython'); python.exec('import rpy2.robjects')
> R is already initialized
> ```

I don't know rPython at all, but surely this is an rPython bug.  When
the package is loaded by "library('rPython')", R is obviously
initialized.  You don't need to query it to ask that.

The standard R front-ends don't need a flag to know if it is
initialized.  They initialize, then go into the read-eval-print loop.
If they are in that loop, R is initialized.  If it failed to initialize,
they would never get to that loop.

Other front-ends may do other things besides run R, so they do need to
know if it is initialized, but surely they can keep a flag telling them
whether they've succeeded in initializing it.

Duncan Murdoch



[Rd] C-API: check whether R has been initialized ?
Duncan Murdoch