Skip to content

as.name is not idempotent

2 messages · Douglas Bates, Peter Dalgaard

#
At least I think the word I want "idempotent" - it has been a long
debugging session and my brain is fried so I am not sure.

What I mean is that as.name applied to a name gives an error.
 > as.name("foo")
 foo
 > as.name(as.name("foo"))
 Error in as.name(x) : character argument required

It might help if it were a bit more flexible about the arguments it
accepts.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Douglas Bates <bates@stat.wisc.edu> writes:
I.: f(f(x)) == f(x) all x, so it's exactly the right term...
This is plainly a bug. If it bothers you badly, insert 

if(is.name(x)) return(x)

at the start of as.name.

In general, it should invariably hold that

is.xx(x) == TRUE implies as.xx(x) == x
and
is.xx(as.xx(x)) == TRUE unless as.xx fails