From pdalgd at gmail.com  Tue Jun  6 20:37:47 2017
From: pdalgd at gmail.com (peter dalgaard)
Date: Tue, 6 Jun 2017 20:37:47 +0200
Subject: [Rd] Unexpected interaction between missing() and a blank
 expression
In-Reply-To: <HK2P15301MB0083C322D8EB5606878CFC60A6CB0@HK2P15301MB0083.APCP153.PROD.OUTLOOK.COM>
References: <HK2P15301MB0083C322D8EB5606878CFC60A6CB0@HK2P15301MB0083.APCP153.PROD.OUTLOOK.COM>
Message-ID: <3E910E0D-D822-4FBC-AE31-8B9751B64109@gmail.com>


> On 6 Jun 2017, at 18:50 , Hong Ooi via R-devel <r-devel at r-project.org> wrote:
> 
> This is something I came across just now:
> 
> f <- function(x) missing(x)
> z <- quote(expr=)
> 
> f(z)
> # TRUE
> 
> The object z contains the equivalent of a missing function argument. Another method for generating a missing arg would be alist(a=)$a .
> 
> Should f(z) return TRUE in this case? I interpret missing() as checking whether the parent function call had a value supplied for the given argument. Here, I have supplied an argument (z), so I would expect f to return FALSE.

Missing values propagate in R, e.g.

> f <- function(x) missing(x)
> g <- function(y) f(y)
> g()
[1] TRUE

This is technically done by having a "missing" object, which is not really intended to be visible to users, but pops up in a few esoteric constructions. Trying do anything constructive with the missing object usually leads to grief, or at least surprises, e.g.:

> z <-quote(expr=)
> z <- z
Error: argument "z" is missing, with no default

-pd
-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] Unexpected interaction between missing() and a blank expression
peter dalgaard