Hi all, I think there's a small buglet in quote: str(quote()) # Error in quote() : 0 arguments passed to 'quote' which requires 1 str(quote(expr = )) # symbol I bring this up because this seems like the most natural way of capturing the "missing" symbol with pure R code, compared to substitute() or bquote() or formals(plot)$x Hadley -- Chief Scientist, RStudio http://had.co.nz/
On Feb 18, 2013, at 16:20 , Hadley Wickham wrote:> Hi all, > > I think there's a small buglet in quote: > > str(quote()) > # Error in quote() : 0 arguments passed to 'quote' which requires 1 > str(quote(expr = )) > # symbol >If there is a bug here, I'd say that it is in str(), revealing the implementation of the missing value as the symbol ``, which we otherwise try not to disclose to R code, e.g.> as.symbol("")Error in as.symbol("") : attempt to use zero-length variable name There's a difference between passing 0 arguments and passing a missing argument and I see nothing particularly wrong with quote(expr=) returning missing. It is, for instance, reasonably consistent that> eval(quote(expr=))Error in eval(expr, envir, enclos) : argument is missing, with no default> I bring this up because this seems like the most natural way of > capturing the "missing" symbol with pure R code, compared to > substitute() or bquote() or formals(plot)$xAre you sure you want to do that? I tend to think that it belongs in the "if it breaks, you get to keep both pieces" category. -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
I wouldn't count on any way of capturing this thing being reliable in the long term. As I recall what I do in codetools and the compiler is use features of missing() to test for it, but try to abstract those uses into one or two places only so I can easily change them if missing()'s behavior changes. Basically this internal thing _shouldn't_ be visible at R level, and if we ever figure out how to make that happen it will. Best, luke On Mon, 18 Feb 2013, Hadley Wickham wrote:> Hi all, > > I think there's a small buglet in quote: > > str(quote()) > # Error in quote() : 0 arguments passed to 'quote' which requires 1 > str(quote(expr = )) > # symbol > > I bring this up because this seems like the most natural way of > capturing the "missing" symbol with pure R code, compared to > substitute() or bquote() or formals(plot)$x > > Hadley > >-- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics and Fax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tierney at uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
Apparently Analagous Threads
- How to assign NULL value to pairlist element while keeping it a pairlist?
- new bquote feature splice does not address a common LISP @ use case?
- Mapping parse tree elements to tokens
- [External] REprintf could be caught by tryCatch(message)
- parse data wrong for R 4.0. raw strings