Skip to content
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

Empty pairlist entries (argument lists) #986

Closed
flying-sheep opened this issue Aug 7, 2019 · 5 comments
Closed

Empty pairlist entries (argument lists) #986

flying-sheep opened this issue Aug 7, 2019 · 5 comments

Comments

@flying-sheep
Copy link

Getting the formals of a function results in pairlists with only named entries, but sometimes empty values:

> formals(bquote)
$expr

$where
parent.frame()
> formals(bquote)[[1L]]

> str(formals(bquote)[[1L]])
symbol 
> as.character(formals(bquote)[[1L]])
""

Looks like this is the empty symbol, but I don’t seem to be able to construct it:

> as.symbol('')
Error in as.symbol(""): attempt to use zero-length variable name
> Rcpp::evalCpp('Rcpp::Symbol("")')
Error in fun(): attempt to use zero-length variable name

How can I programmatically construct a pairlist with empty values like this?

@flying-sheep
Copy link
Author

flying-sheep commented Aug 7, 2019

Found it:

The error comes from Rf_install. There’s an internal function mkSYMSXP, redefined to Rf_mkSYMSXP in the internal header Defn.h.

There seem to be a bunch of marker symbols exported from Rinternals.h, among them … R_MissingArg.

@eddelbuettel
Copy link
Member

Right. When I saw this (before I went out to run) I wondered what this could conceivably have to do with Rcpp. Guess my hunch was correct...

@flying-sheep
Copy link
Author

I don’t know the C API for pairlists and couldn’t find any example on how to construct an Rcpp::Pairlist with Named("foo", R_MissingArg). Maybe we should add this as an example for #987.

@eddelbuettel
Copy link
Member

Please stop debating base R APIs here. We don't have the staff and bandwidth, and you know where to find the r-devel mailing list.

@eddelbuettel
Copy link
Member

Also FWIW and IIRC the few times pair lists came up on the r-devel or alike lists, I do recall R Core members stating just about each and every time that they are either deprecated or not meant to be seen at the API. Maybe try want you want to do with a simple list instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants