Returns an external pointer to the SEXP (R object header) while ensuring the object won't be garbage collected as long as the pointer exists.
Examples
if (FALSE) { # \dontrun{
x <- c(1L, 2L, 3L) # Use c() not 1:3 to avoid ALTREP
ptr <- sexp_ptr(x)
# ptr is now safe to pass to C functions expecting SEXP
# When ptr is garbage collected, the protection is released
} # }