-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full Altrep Support #250
Full Altrep Support #250
Conversation
Super, thanks! Could you add some comments that explain what the various API functions do? |
extendr-api/src/wrapper/altrep.rs
Outdated
fn serialized_state(&self) -> Robj { | ||
().into() | ||
} | ||
|
||
/// Duplicate this object, possibly duplicating attributes. | ||
fn duplicate_ex(&self, _deep: bool) -> Robj { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "ex" stand for? "extended"? Can you think of a different choice that is a little more intuitive?
I'm not sure yet how we will define new Altrep classes. Given a trait like the ones described, we should be able to make a "universal adapter" from the Altrep To test, I'll implement |
@@ -422,6 +424,37 @@ pub enum RType { | |||
Unknown, | |||
} | |||
|
|||
pub fn rtype_to_sxp(rtype: RType) -> i32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a brief, 1-2 sentence documentation would be helpful here also.
I'm probably going to narrow the definition of Altrep to make it easier to use. Altrep objects have
If we always use a struct for the state object (ie. Extptr) we can implement In an ideal world, we would just need to implement the "elt" method for an The state object should be a regular Rust object rather than an R object. struct MyCompactIntRange {
start: i32,
length: i32,
step: i32,
}
impl AltIntegerImpl for MyCompactIntRange {
fn elt(&self, index: usize) -> i32 {
self.start + self.step * index
}
}
let mystate = MyCompactIntRange { start: 1, length: 10, step: 1 };
let myobj = Altrep::new(mystate); |
|
@yutannihilation did we establish a mechanism for using #[cfg] with libR-sys? If so, I can screen out some of the newer features. The |
(Sorry, I forgot to answer...) Yes, for internal usages within extendr crates, we can set cfg in build.rs. Lines 10 to 17 in 6cf4c1b
In case a feature is not available in the older versions of R, it sounds the right thing to do. But, this time, the case is that it's not available on the newer version, which means we'll need to remove it in future when the current versions are out of the range of our minimum supported version. So, I'm wondering if it's worth the effort... |
Yeah, I had the same thoughts. If it's a feature that is going away we should just work without for all R versions. Or, if critical, reach out to the R core developers and ask them to not remove the feature. |
For |
Or just |
Claus is right that we can't rely on the functions now in The sum, min and max functions should work for code, so we can always I still have to implement defaults duplicate and coerce, but then we can merge. I am planning to finish off the last few SXP types as part of the grant contract. |
This PR adds an "Altrep" wrapper and the beginnings of the means to implement new Altrep classes.