[Rd] bug in callNextMethod (PR#14185)

2010-01-13 Thread bernd_bischl
Hi,

there seems to be a possible bug in callNextMethod in conjunction with 
the [-operator.

Relevant info, minimal example and sessionInfo follow below:

###

setClass("foo", representation = representation(a = "numeric"))
setClass("bar", contains = "foo")

setMethod(
f = "[",
signature = signature("foo"),
def = function(x,i,j,...,drop=TRUE) {
cat("drop in foo-[ :", drop, "\n")
return(1)
}
)

setMethod(
f = "[",
signature = signature("bar"),
def = function(x,i,j,...,drop=TRUE) {
cat("drop in bar-[ :", drop, "\n")
# we lose the value of drop here, when the call gets 
dispatched to the super method by callNextMethod
callNextMethod()
}
)

x <- new("foo")
x[1, drop=FALSE]
# drop in foo-[ : FALSE
y <- new("bar")
y[1, drop=FALSE]
# drop in bar-[ : FALSE
# drop in foo-[ : TRUE 

###

#?callNextMethod
#The statement that the method is called with the current arguments is 
more precisely as follows. Arguments that were missing in the current 
call are still missing (remember that "missing" is a valid class in a 
method signature). For a formal argument, say x, that appears in the 
original call, there is a corresponding argument in the next method call 
equivalent to x = x. In effect, this means that the next method sees the 
same actual arguments, but arguments are evaluated only once.

###


#S3 gets this right:

'[.foo' <- function(x, i, j, ..., drop=TRUE) {
cat("drop in foo-[ :", drop, "\n")
}
   
'[.bar' <- function(x, i, j, ..., drop=TRUE) {
cat("drop in bar-[ :", drop, "\n")
NextMethod()
}

x <- 1
class(x) <- c("bar", "foo")
x[1, drop=FALSE]
# drop in bar-[ : FALSE
# drop in foo-[ : FALSE

###

 > sessionInfo()
R version 2.11.0 Under development (unstable) (2010-01-12 r50970)
i386-pc-mingw32

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252  
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C  
[5] LC_TIME=German_Germany.1252   

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_2.11.0

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] small bug in base::formatC (PR#13474)

2009-01-27 Thread bernd_bischl
Full_Name: Bernd Bischl
Version: 2.8.1
OS: Windows XP Professional
Submission from: (NULL) (129.217.207.95)


Hi,

there seems to be a small bug in formatC:

formatC("foo", format="s", mode="charcacter")

Error in formatC("foo", format = "s", mode = "charcacter") : 
  'mode' must be "double" ("real") or "integer"

?formatC
says:

mode:  "double" (or "real"), "integer" or "character". Default: Determined from
the storage mode of x 

I tested this in the 2.8.1 release and the latest development version, both on
XP Professional.

sessionInfo for the second one:

R version 2.9.0 Under development (unstable) (2009-01-22 r47686) 
i386-pc-mingw32 

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 

Regards,

Bernd Bischl

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel