Re: R-beta: 'all.names' function -- failing as.list( _function_ )

Martin Maechler (
Mon, 28 Apr 97 17:07:05 +0200

Date: Mon, 28 Apr 97 17:07:05 +0200
Message-Id: <9704281507.AA00504@>
From: Martin Maechler <>
In-Reply-To: <> (message from Douglas Bates
Subject: Re: R-beta: 'all.names' function -- failing   as.list( _function_ )


your 'all.names' function
	[wow, I didn't even know it in S..]
seems to have been written with S in your mind;
you are exactly demonstrating some of the 'fine' differences between  R & S

>1> all.names <- function (x) 
>2> {
>3>   if (mode(x) == "symbol")  return(as.character(x))
>4>   if (length(x) == 0)       return(NULL)
>5>   if (is.recursive(x))      return(unlist(lapply(as.list(x), all.names)))
>6>   character(0)
>7> }   

1) length(x) is not always defined in R; e.g. it is NOT for functions.
   --> Delete line 4  

2) functions  are NOT lists and cannot be coerced to,
   which makes line 5 fail for function objects.

As a matter of fact, I once was also a bit interested in this.
At that time, 'args' did not yet exist, and I wanted to abuse 'as.list' for
I was told that this is 'bad'
	(functions have nothing to do with lists;
	 in R, functions can have a defining environment going with them...)
and 'args' is now provided which helps my most immediate need.

In short: I don't think  you can define an  all.names(.) function which
	  works with functions arguments, in the current version of R.

r-help mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: