Expand description
§Typed-SEXP
Type-safe manipulation of R’s SEXP objects without bells and whistles.
§Objectives
R internal API is very confusing and not type-safe.
However many times I do not want to pull in huge proc macros just to write my R extension. The main reasons are:
- Macros in general are hard to debug.
- Macros mess up static analysis tools.
- Macros hide the actual code that is being generated.
This library is an attempt to provide a type-safe interface to R’s SEXP objects without any user-exposed macros.
However it is not a goal to provide a high-level abstractions over R’s API like Rcpp or extendr, the most I will do is type-safe indexing, attributes, calling functions, etc.
Users are expected to have a general understanding of R internals.
Here is a quick tutorial.
§Features
- Typed SEXP objects that are ABI-compatible with R’s SEXP.
- Type-safe (mutable) indexing of vectors and matrices.
- Typed protection of SEXP objects with a debug mode that sanity-checks the protection order.
- Stack RAII-based auto un-protection of SEXP objects.
- Downcasting of SEXP objects in a method chain with a single call (even if the object is wrapped in another abstraction).
- Namespace and function objects that are environment-aware.
- Call R functions with type-safe arguments and return values.
- (TODO): Dynamically create R functions.
Re-exports§
pub use libR_sys;
Modules§
- message
- Emit user messages and errors to R with
OptionandResultextensions. - prelude
- Common traits and types for working with this crate.
- protect
- Abstractions for protecting R objects from garbage collection.
- sexp
- This module contains typed wrappers for R’s SEXP type.
Enums§
- AnySexp
- Any supported SEXP type.
Traits§
- DowncastSEXP
- Type refinement of another
SEXP-wrapping type. - HasSEXP
- A trait for objects that have an underlying
SEXP. - IndexableSEXP
- A
SEXPwrapper that can be indexed. - JustSEXP
- Trivial, ABI-compatible wrapper types around
SEXP. - ProtectedSEXP
- Trait for types whose
SEXPis protected. - TypedSEXP
- A trait for objects that have an static underlying
SEXPTYPE.
Functions§
- null
- The null SEXP.