dgkf / dgkf/R

Pilot interface to `extendr/libR-sys` for bootstrapping R internals

Open
#14 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
145
Forks
5
PR merge metrics
No merged PRs in 30d

Description

As a first pass, I think just hooking up `Rf_isNull` would be a good minimal example that might help design the broad data flow from rust to `libR` and back to rust. Naturally, building `is.null` in pure rust would be straightforward, so the value here is purely in minimizing the scope to explore the data interop between the two.

This would mean converting from an `R` (this crate) to a `libR-sys` `SEXP` which then calls the C binding, returning a C `SEXP`, converting to a `libR-sys` `SEXP` and back to a `R` (this crate).

I anticipate that it won't look super pretty, almost undoubtedly with a data conversion to and from `libR`'s `SEXP` model, but it would help to fill a gap until the library can be built up as a rust-native solution.

The goal is the ability to define a

```r
is.null <- function(x) .Primitive("is.null")
```

And have it leverage the `libR` version's internal definition.

Steps to implementation:

- Implement `Into` for `r::R`, which under the hood will convert to the various types defined in https://extendr.github.io/extendr/extendr_api/wrapper/index.html and use those as intermediaries for the conversion to `libR-sys::Robj`.
- Implement `.Primitive` (and `.Internal`?) which call internals with conversion first to `libR-sys::Robj`
- Implement `From` for `r::R`

This will probably result in a lot of data duplication any time a primitive or internal is called, but I'd like to put that out of mind for this first implementation just to get to the point where we can bootstrap a standard library with a huge set of existing R internals.

Conceptually it sounds pretty reasonable. Am I missing anything?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.