From pdalgd at gmail.com  Mon Feb 18 16:53:50 2013
From: pdalgd at gmail.com (peter dalgaard)
Date: Mon, 18 Feb 2013 16:53:50 +0100
Subject: [Rd] quote() vs quote(expr=)
In-Reply-To: <CABdHhvGwS1xuOqYLqtJAGjJrm5gGvLW7XJs+4bg3LY_R3Z7oNQ@mail.gmail.com>
References: <CABdHhvGwS1xuOqYLqtJAGjJrm5gGvLW7XJs+4bg3LY_R3Z7oNQ@mail.gmail.com>
Message-ID: <01CE77E8-6F40-4050-A365-A21DFF933585@gmail.com>


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)$x

Are 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



[Rd] quote() vs quote(expr=)
peter dalgaard