The R Project SVN R

Rev

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

Rev 22734 Rev 22949
Line 32... Line 32...
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
## Tests S3 dispatch with the class attr forced to be data.class
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
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")
-
 
39
abc <- function(x, ...) {
37
abc <- function(x, ...) {
40
    if (is.null(baseClass(x))) baseClass(x) <- data.class(x)
38
    if (is.null(oldClass(x))) oldClass(x) <- data.class(x)
41
    cat("abc: Before dispatching; x="); str(x)
39
    cat("abc: Before dispatching; x="); str(x)
42
    UseMethod("abc", x,...) ## UseMethod("abc") (as in S) fails
40
    UseMethod("abc", x,...) ## UseMethod("abc") (as in S) fails
43
}
41
}
44
 
42
 
45
abc.default <- function(x, ...) sys.call()
43
abc.default <- function(x, ...) sys.call()