R-alpha: R-0.50-a3(+) Method despatching bug ?

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Wed, 20 Aug 1997 17:52:53 +0200


It is very wierd...  Can some of you confirm the following behavior ?
It is a new bug (feature ?)  which was not yet in 0.49 ...




noquote <- function(obj) {
	## constructor for a useful "minor" class
	if(!inherits(obj,"noquote")) class(obj) <- c(class(obj),"noquote")
	obj
}
"[.noquote" <- function (x, subs) structure(unclass(x)[subs], class = "noquote")

print.noquote <- function(obj,...) {
	## method for (character) objects of class 'noquote'
	cl <- class(obj)
	class(obj) <- cl[cl != "noquote"]
	NextMethod("print", obj, quote = FALSE, ...)
}

nq <- noquote(letters)

##-- the next two should be equivalent, but are not ...?..
print(nq)
nq

> print(nq)
 [1] a b c d e f g h i j k l m n o p q r s t u v w x y z

> nq
Error: couldn't find function "print.noquote"
> unclass(nq)
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
[20] "t" "u" "v" "w" "x" "y" "z"
> nq
Error: couldn't find function "print.noquote"
> ls()
[1] "[.noquote"     "noquote"       "nq"            "print.noquote"
> print.noquote
function (obj, ...) 
{
        ## method for (character) objects of class 'noquote'
        cl <- class(obj)
        class(obj) <- cl[cl != "noquote"]
        NextMethod("print", obj, quote = FALSE, ...)
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-