Skip to content
Prev 32018 / 63424 Next

dput(as.list(function...)...) bug

Duncan Murdoch wrote:
Yes, it actually is the zero-length name that is being used for this, 
but that is not really useful knowledge because it is forbidden to 
create them as `` or as.name(""). We did briefly consider making the 
missing object a real R object, but the semantics are too weird:

Basically, you can only assign it once, next time you get errors:

 > x <- alist(a=)$a
 > missing(x)
[1] TRUE
 > y <- x
Error: argument "x" is missing, with no default
 > l <- alist(a=, b=2)
 > l$b <- x
Error: argument "x" is missing, with no default

And, as you think about it, you realize that you cannot disable these 
mechanisms, because _something_ has to trap use of missing arguments.

It does actually work to define a function mvi() which returns the 
missing value indicator and have things like

 > list(x= mvi(), b= quote(!x))
$x


$b
!x

work. I'd hate writing its help page, though.