The arcane formals(function(x){})$x

Background: What is formals(function(x) {})?

Well, to start with (and as documented in ?formals) , formals(function(x) {}) returns a pairlist:

is(formals(function(x){}))
# [1] "pairlist"

Unlike list objects, pairlist objects can have named elements that contain no value -- a very nice thing when constructing a function that has a possibly optional formal argument. From ?pairlist:

tagged arguments with no value are allowed whereas ‘list’ simply ignores them.

To see the difference, compare alist(), which creates pairlists, with list() which constructs 'plain old' lists:

list(x=, y=2)
# Error in list(x = , y = 2) : argument 1 is empty

alist(x=, y=2)
# $x
# 
# $y
# [1] 2

Your question: What is formals(function(x) {})$x?

Now to your question about what formals(function(x) {})$x is. My understanding is in some sense its real value is the "empty symbol". You can't, however, get at it from within R because the "empty symbol" is an object that R's developers -- very much by design -- try to entirely hide from R users. (For an interesting discussion of the empty symbol, and why it's kept hidden, see the thread starting here).

When one tries to get at it by indexing an empty-valued element of a pairlist, R's developers foil the attempt by having R return the name of the element instead of its verbotten-for-public-viewing value. (This is, of course, the name object shown in your question).


It's a name or symbol, see ?name, e.g.:

is(as.name('a'))
#[1] "name"      "language"  "refObject"

The only difference from your example is that you can't use as.name to create an empty one.