knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

rvee

Recreational V programming for R / WIP

CRAN status R-CMD-check

Early work! (not ready for production)

Create R extension packages with the V programming language. V is a simple, safe and fast programming language with the speed of C.

R has good interfaces for many programming languages such as C , fortran , cpp (e.g. Rcpp) , python (e.g. reticulate) and rust (e.g. r-rust). R Package rvee intends to provide an easy toolkist for creating R packages with the v programming language.

Status

Translation to C and compilation 🎉!

Interfacing:

r module (in v):

Installation

The unstable development version from GitHub with:

# install.packages("devtools")
devtools::install_github("edwindj/rvee")

Overview

Possible routes for creating an R extension with v code are:

a) Transpiling V code to C code and use it as a normal C extension. b) Using the v compiler to build a shared library linked to the R shared library.

Both options have their benefits and draw backs:

a) Allows for easy distribution and installation, but requires tweaking the compilation flags to pass CRAN checks etc. and removing/stripping code that is not needed by R.

b) Allows for an optimized shared library, but requires v to be installed by the installer (e.g. CRAN).

Example

Transpiling to C works.

Put your v files in the "<pkg>/src/v" directory and decorate each function to be exported with the [rv_export] attribute (see example below).

After that

rvee::rv_export_c generates the necessary interfacing code:

After that devtools::load_all (or R CMD SHLIB) work: they will compile "init.c" and "<pkg>.c" into "<pkg>.so"/"<pkg>.dll".

Suppose we have the following file "/src/example.v"


With:

rvee::rv_export_c("<pkg>", prefix="my_pkg") # <pkg> is root dir of the source of your package...

The interfacing code is generated:

"<pkg>/src/v/rv_export.v":

```r
fns <- rvee:::scan_v_file("example/example.v")
pkg <- "my_pkg"
rvee:::generate_rv_export_v(fns,pkg=pkg)
and 

`"<pkg>/R/rv_export.R"`:

```r
```r
rvee:::generate_rv_export_R(fns, pkg = pkg)
And create the shared library with a call to devtools

```r
devtools::load_all("<pkg>")


edwindj/rvee documentation built on June 23, 2022, 11:30 p.m.