Skip to content
Prev 169086 / 398506 Next

sub question

Wacek Kusnierczyk wrote:

            
By calling a recursive function which has it as the argument. It's not a 
problem unless you want it to be (first you descend into the first 
element on a call, then realize that it is a name). There are 
essentially three possibilities (cutting some red tape):

 > f <- function(e) if (is.name(e))
   print(e) else if(is.call(e)) invisible(lapply(e,f))
 > f(~ fo(o)())
`~`
fo
o


 > f <- function(e) if (is.name(e))
  print(e) else if(is.call(e)) invisible(lapply(e[-1],f))
 > f(~ fo(o)())


 > f <- function(e) if (is.name(e)) print(e) else
         if(is.call(e)) invisible( if(is.name(e[[1]]))
              lapply(e[-1],f) else lapply(e,f))
 > f(~ fo(o)())
o


The first two are essentially the current all.names and all.vars. The 
third is the one that you seem to expect. Notice that it gets rather 
more complicated than the others.

  > one legitimate reason is to keep the syntax/semantics clean (worship the
But can you be sure that there is no legitimate reason for expecting the 
current behaviour?