The R Project SVN R

Rev

Rev 8504 | Rev 22949 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8504 Rev 22734
Line 30... Line 30...
30
 
30
 
31
 
31
 
32
### ------------  was ./mode-methods.R till R ver. 1.0.x ----------------
32
### ------------  was ./mode-methods.R till R ver. 1.0.x ----------------
33
 
33
 
34
###-- Using Method Dispatch on "mode" etc :
34
###-- Using Method Dispatch on "mode" etc :
35
 
-
 
-
 
35
## Tests S3 dispatch with the class attr forced to be data.class
-
 
36
## Not very relevant when S4 methods are around, but kept for historical interest
-
 
37
baseClass <- get("class", "package:base")
-
 
38
"baseClass<-" <- get("class<-", "package:base")
36
abc <- function(x, ...) {
39
abc <- function(x, ...) {
37
    if (is.null(class(x))) class(x) <- data.class(x)
40
    if (is.null(baseClass(x))) baseClass(x) <- data.class(x)
38
    cat("abc: Before dispatching; x="); str(x)
41
    cat("abc: Before dispatching; x="); str(x)
39
    UseMethod("abc", x,...) ## UseMethod("abc") (as in S) fails
42
    UseMethod("abc", x,...) ## UseMethod("abc") (as in S) fails
40
}
43
}
41
 
44
 
42
abc.default <- function(x, ...) sys.call()
45
abc.default <- function(x, ...) sys.call()