[Rd] Is this an incorrect use of the R-API?

Duncan Temple Lang dtemplelang at ucdavis.edu
Sun Oct 12 21:45:24 CEST 2014


Hi Utkarsh

 If the package is an experiment and exploration, great - good for you 
 getting into this level of detail.
 However, if your goal is to get the dynamic prompt, a simpler mechanism
 that is almost equivalent is the R code

 invisible(addTaskCallback(function(...) { 
                             options(prompt = format(Sys.time(), "[%H:%M:%S] >"))
                             TRUE
                           }))

  The only difference is that when you hit return at the prompt with no expression,
  the prompt doesn't change (since there was no task).


  As for incorrectly using the API - yes. Since R CMD check is telling you this is a
  problem, it is officially a problem. This is of no consequence if the package works for you and any
  users of it, and the package is not to be hosted on CRAN. However, using this symbol in your code may not 
  work on all platforms, and is not guaranteed to work in the future (but probably will!). 

   D.
   

On 10/12/14, 8:13 AM, Utkarsh Upadhyay wrote:
> Hi,
> 
> I am trying to create a small extension for R here for embedding the
> current time on the R prompt: https://github.com/musically-ut/extPrompt
> 
> Things seem to be working overall, but `R CMD check .` raised a warning:
> 
>> File '[truncated]..Rcheck/extPrompt/libs/extPrompt.so’:
>>  Found non-API call to R: ‘ptr_R_ReadConsole’
>>
>> Compiled code should not call non-API entry points in R.
> 
> The concerned file is this:
> https://github.com/musically-ut/extPrompt/blob/master/src/extPrompt.c and
> occurs on line 38, I think [1].
> 
> I am trying to make the R_ReadConsole API call. However, since a different
> plugin (like mine) could have overridden it already, I do not want to
> directly invoke `R_ReadConsole` but the function which previously was at
> `ptr_R_ReadConsole`.
> 
> Is this an incorrect use of the API?
> 
> Thanks!
> 
> Best Regards,
> Utkarsh Upadhyay
> http://musicallyut.in
> 
> [1]: I am impressed at how well the static code analysis works for R CMD
> check.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list