[R] alist() and missing variables

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Mon May 2 21:37:46 CEST 2022


Hi,

I've been playing around with formals() and stumbled upon some
behaviour which surprised me:

a <- alist(x=)
.Internal(inspect(a$x))
# @55b0ebae67b0 01 SYMSXP g0c0 [MARK,REF(5761)] "" (has value)
x <- a$x
.Internal(inspect(x))
# Error: argument "x" is missing, with no default
missing(x)
[1] TRUE

Apparently, the elements corresponding to formal arguments without a
default value can be passed to functions as arguments (and look like
empty symbols, which can't be created by as.symbol()), but when
assigned to a variable, they turn missing and can't be accessed.

How can I safely detect and work with such values?

-- 
Best regards,
Ivan



More information about the R-help mailing list