From krunal.rao78 at gmail.com  Fri Nov 11 00:24:10 2011
From: krunal.rao78 at gmail.com (KR)
Date: Thu, 10 Nov 2011 23:24:10 +0000
Subject: [Rd] Question on parsing R code from C
References: <loom.20111108T203022-872@post.gmane.org>
	<9465BE63-EA88-4BE2-8D1C-9E33BE8AA45D@r-project.org>
	<loom.20111108T224700-655@post.gmane.org>
	<3D4F776D-4D5D-4C39-90B3-12DF09C5C6BA@r-project.org>
	<loom.20111109T001139-68@post.gmane.org>
	<AF0744B1-C119-4BF1-99D0-9DBA31E734F9@r-project.org>
Message-ID: <loom.20111111T000844-348@post.gmane.org>

First of all thanks a lot to you both for all the replies, they have been of 
great help to me!

I got the basic embedding running, however I still have some issues to solve in 
order to complete the interface to R I am working on:

1. I initialize with Rf_initEmbeddR().
- Is there a way to have more than one R "state" (per single thread)? Or is 
everything necessarily global?
- I also read somewhere that the fpu settings may be touched. Is there a way to 
make sure that this is not the case? Is this related to fpu_setup()?

2. I create a string and parse it via Rf_mkString() and R_parseVector() (yes I 
protect/un-protect the SEXPs).
- Is it possible to obtain the precise error message, like "unexpected symbol 
in..." (as would be reported by R.exe) in case of error as a const char* string?
- If I pass a wrongly escaped string (for instance 'ggsave("C:\gtest.png")', 
please notice the missing \) I get on stderr: Error '\g' is an unrecognized 
escape and I get a crash. This does not happen if for instance i try to parse 
'rnorm(10a10)' in which case I get the error flag and the NULL ptr return. I 
suspect I need to initialize something / set a callback to avoid this but I am 
not sure...

3. I eval with R_tryEvalSilent().
- Again, is it possible to obtain the precise error message in case of 
evaluation error as would be reported from R.exe?

4. Regarding the returned result of evaluation.
- What is the correct way to obtain a const char* string representing the result 
as would be "printed" in the R shell by executing a command (for instance 
"summary(c(1,2,3))") ?
- Why is the return type (as reported from typeof in R and TYPEOF in C) of 
"summary(c(1,2,3))" a double?

Any help / feedback on these issues would be greatly appreciated.

Thanks again.



[Rd] Question on parsing R code from C
KR