Warning
This post was published 37 days ago. The information described in this article may have changed.
Hi all! I has been thinking in try a project which I don't know where to start, I'm checking if doing it and there is some reasons I would like to give it a try at work.
The idea is write rust code, be able to use r-a and everything, and then that code transform it to other language, for practical things I'll say/choose R for now, but would be nice keep in mind to do it with any language.
Why?
Well, this is some of the cases... going to the issue, any has any idea how to do this?
I tried checked on this, I would like to avoid this:
r_let!(let a = 10);
I thought in use attribute macros, this allow use to check all lines, and do the conversions for each instruction, the issue I found in this was that how to write the final result to a file, seems the attribute macros do not have a guarantee order or execution, still if with cargo clean
we can force it, still is fine, still no idea if this is the right thing.
I was thinking to implement something like a trait ToR
which would transform each expression to R, some parts must be done out (like in a macro), and this would help to organize the code better, because I would need to have the R libs, in this case how are the signatures of the types and functions, have modules with each lib and how they are transformed is nice.
There is also the alternative to write a app that reads rust code and transform to R, but this could also be complex, I would not even know how to call ToR
...
Ideas?
My ideal is be able to write something like (trivial example):
#[to_r, file = "foo.R"]
fn foo(a: f64, b: f64) -> r::sf::Point {
let a = a*2;
let b = b*a;
r::sf::Point::new_xy(a, b)
}
which could lead to
foo <- function(a, b) {
a <- a*2
b <- b*a
ret <- sf::st_point(c(a, b))
a <- NULL
b <- NULL
ret
}
Thx!
1 post - 1 participant
🏷️ rust_feed