r-lib / cpp11

cpp11 helps you to interact with R objects using C++ code.
https://cpp11.r-lib.org/
Other
199 stars 46 forks source link

Add a debug string representation accessor to `cpp11::sexp` #211

Open bkietz opened 3 years ago

bkietz commented 3 years ago

It'd be helpful for error messages, logging, and other debugging to have easy access to a string representations for SEXPs in C++. This could return the equivalent of .Internal(inspect(some_sexp)) or capture.output(print(some_sexp)).

See original discussion here: https://github.com/r-lib/cpp11/pull/209#discussion_r674209915

cpp11::sexp value = ...
std::string str = value.inspect();
std::string str = value.inspect(/*depth=*/2); // limit inspection of sub objects