Open
Conversation
e544706 to
354298d
Compare
DavisVaughan
approved these changes
Mar 5, 2026
Comment on lines
-129
to
+133
| unsafe { libr::OBJECT(object) != 0 } | ||
| unsafe { libr::Rf_isObject(object) != 0 } | ||
| } | ||
|
|
||
| pub fn r_is_s4(object: SEXP) -> bool { | ||
| unsafe { libr::IS_S4_OBJECT(object) != 0 } | ||
| unsafe { libr::Rf_isS4(object) != 0 } |
Contributor
There was a problem hiding this comment.
Can you please go through r.rs and remove anything we no longer need? Like I see OBJECT and IS_S4_OBJECT are still in there, and it would be nice to remove them so we don't accidentally use them again.
Comment on lines
-163
to
-164
| // First replace the body which contains expressions tagged with srcrefs | ||
| // such as calls to `{`. Compiled functions are a little more tricky. |
crates/harp/src/r.rs
Outdated
| } | ||
|
|
||
| /// Creates a closure. | ||
| pub unsafe fn new_function(formals: SEXP, body: SEXP, env: SEXP) -> SEXP { |
Contributor
There was a problem hiding this comment.
do you want it to be unsafe?
crates/harp/src/r.rs
Outdated
Comment on lines
+62
to
+75
| compat::alloc_closure(formals, body, env) | ||
| } | ||
| } | ||
|
|
||
| mod compat { | ||
| use libr::SEXP; | ||
|
|
||
| pub unsafe fn alloc_closure(formals: SEXP, body: SEXP, env: SEXP) -> SEXP { | ||
| let out = libr::Rf_allocSExp(libr::CLOSXP); | ||
| libr::SET_FORMALS(out, formals); | ||
| libr::SET_BODY(out, body); | ||
| libr::SET_CLOENV(out, env); | ||
| out | ||
| } |
Contributor
There was a problem hiding this comment.
it feels more useful to me to just inline this. we'd only ever use it in this 1 place probably?
DavisVaughan
reviewed
Mar 5, 2026
Comment on lines
+114
to
+119
| /// Copies all attributes from `src` to `dst`. | ||
| pub fn attrib_poke_from(dst: SEXP, src: SEXP) { | ||
| attrib_for_each(src, |tag, val| unsafe { | ||
| libr::Rf_setAttrib(dst, tag, val); | ||
| }); | ||
| } |
Contributor
There was a problem hiding this comment.
Why not DUPLICATE_ATTRIB or SHALLOW_DUPLICATE_ATTRIB?
Contributor
Author
There was a problem hiding this comment.
Good catch, should be shallow-duplicate as in https://github.com/r-lib/rlang/pull/1873/changes#diff-4abaa2fa8b7c6338784d3376cb679dcf2a5ad2338b416544767314699e3f9089
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branched from #1076
R core just removed access to a bunch of APIs, just in time to put our new r-devel build (#1076) to good use.
The main change is that we no longer unlock our private namespaces and environments. Instead we wait until they are fully initialised to lock them. In debug builds we never lock them to allow hot-reloading when a .R file changes.
Otherwise we follow what we've been doing in rlang, lobstr, vctrs, and other packages regarding compatibility with C API. E.g. in
zap_srcref()orobj_size(). We use new APIs (with polyfills for old R compats) or new workaround approaches.I've also proactively removed usage of
ATTRIB()andSET_ATTRIB()as well (except in the altrep utils) since these have been promoted from NOTE to WARNING on CRAN.