Re: [Rd] example package for devel newcomers

From: Alexandre Aguiar <asaguiar_at_spsconsultoria.com>
Date: Tue, 02 Aug 2011 03:01:12 -0300

Em Segunda 01 Agosto 2011, vocÍ escreveu:
> Is there a preferred language you would like to use in your package
> development? I randomly downloaded packages until I found some that
> helped me along my way, and might be able to help you pick one. If you
> are just looking at building a package of R functions and data you
> have developed, possibly the following example will get you started
> till you feel comfortable with the "Writing R Extensions"
> documentation (http://cran.r-project.org/doc/manuals/R-exts.pdf):

Dan, your message is cool. Well, here is what my project is about: it is a package to embed php into R. Named Rphp for now. It is mostly done from scratch. I have loved R-exts.pdf. Great stuff.

Why embed php into R? My primary purpose is to use web content management systems (WCMS) ready and extensively tested code from R cgi scripts. Someone more experienced with php might think of other uses. My approach is RAD(ical) and innovative (IMextremelyHO :-D) because: a) *any* php based WCMS can be used from R code with no php or html coding;
b) output fully compliant with the website appearance; c) WCMS automatic upgrades and interfaces changes (skins or themes) will be so unlikey to cause need for maintenance in R cgi scripts; d) R cgi scripts will not demand changes in php code; e) the builtin php session support obviates the need for any special session coding by R (likely non-web) programmers; f) potential for improved analysis of web databases and even of systems surveillance tasks.

During my explorations of the R interface for extensions and the time spent in this tiny project, some questions emerged.

  1. my code uses no recursion but I do not really know what is inside php code. Stack size could be a concern. Has any of you there ever needed to allocate a new stack for a package? Is it better to wait for complaints (if anyone ever would like to try this package...)?
  2. can R_registerRoutines be called more than once within the same library (the same DllInfo data) so that it can reconfigure itself on the fly?
  3. Is it safe (I guess it is) to "re-export" a function pointer retrieved with R_GetCCallable?
  4. when loading a second library (in this case libphp5.so) is it better to put it in the package library directory and load it using the 'char *path' member of DllInfo? Using a second library has implications: a) a given R setup can be limited to the user space without root access; b) in the case of desktops where someone might use Rphp, most systems do not have libphp5.so installed by default and installing it frequently means to install apache and all (many) related packages; c) many sysadmins do not have root access but can compile their own php version; d) building the libphp5.so may not be an easy task for many.
  5. Similar to 3, is it safe to "export" functions of the second library? libphp5.so will not be registered to R and has some interesting functions that can be "exported" directly or as pointers within Rphp library. A stub function can be used.
  6. related to 4, with the many machine architectures and operating systems around I think it is neither desirable nor feasible to distribute precompiled libphp5.so versions; the package itself can download (wget and curl are everywhere) and compile php. Compiling php is not a lengthy task (6m12.9s in my quadcore desktop) but is a lot tricky and demands several development packages not installed by default in desktop systems. Their installations would require root access. What is the suggested approach to deploy libphp5.so?
  7. I do not know how to produce a version for windows if requested. I have only an old MSC++ 97 and lcc (current) and have xp in a virtual box. This concern includes php. Can I get help regarding windows in this list? It might mean actual work: adapting code, compiling, packaging, etc. Not sure what is needed.
  8. system safety does not seem a concern regarding this use of php, but... Any suggestions?

I guess some manual steps will be necessary because of potential security breaches related to the use of a second library. Patching php to produce a special build to be used as the package library would not be a trivial task and would demand updates at every new php version. Something I can't assure I can do. And would have to distribute the whole php source code: still have to study php licensing scheme.

BTW, I copied Rdynpriv.h by hand to my include path to get access to 'struct _DllInfo' definition. The R install process did not copy this file. Am I doing something wrong here?

Sorry for the lengthy message. Thanx for your help.

-- 


Alexandre

--
Alexandre Santos Aguiar, MD, SCT

______________________________________________ R-devel_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Received on Tue 02 Aug 2011 - 06:08:35 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 02 Aug 2011 - 14:20:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive