SciNim / rnim

A bridge between R and Nim
24 stars 1 forks source link

Add wrapper types for R types #7

Open Vindaar opened 3 years ago

Vindaar commented 3 years ago

For scalar types we can continue to simply copy numbers. However, for larger data we will want to have Nim wrapper types that allow access to the underlying data of the SEXP without copying.

A sketch:

type
  NumericVector[T] = object
    obj: SEXP

proc `[]`[T](v: NumericVector[T], idx: int): T = 
  result = v.obj.accessArray(idx) # where accessArray accesses the data using DATAPTR
...

Need to learn what other types of interest we might want to wrap other than vectors.

Vindaar commented 3 years ago

NumericVector and a related RawVector have been implemented in #12.

This will stay open, as other types should also be wrapped.