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 1... Line 1...
1
 
1
 
2
R : Copyright 2003, The R Development Core Team
2
R : Copyright 2003, The R Development Core Team
3
Version 1.7.0 Under development (unstable) (2003-01-16)
3
Version 1.7.0 Under development (unstable) (2003-02-01)
4
 
4
 
5
R is free software and comes with ABSOLUTELY NO WARRANTY.
5
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
You are welcome to redistribute it under certain conditions.
6
You are welcome to redistribute it under certain conditions.
7
Type `license()' or `licence()' for distribution details.
7
Type `license()' or `licence()' for distribution details.
8
 
8
 
Line 62... Line 62...
62
> ### ------------  was ./mode-methods.R till R ver. 1.0.x ----------------
62
> ### ------------  was ./mode-methods.R till R ver. 1.0.x ----------------
63
> 
63
> 
64
> ###-- Using Method Dispatch on "mode" etc :
64
> ###-- Using Method Dispatch on "mode" etc :
65
> ## Tests S3 dispatch with the class attr forced to be data.class
65
> ## Tests S3 dispatch with the class attr forced to be data.class
66
> ## Not very relevant when S4 methods are around, but kept for historical interest
66
> ## Not very relevant when S4 methods are around, but kept for historical interest
67
> baseClass <- get("class", "package:base")
-
 
68
> "baseClass<-" <- get("class<-", "package:base")
-
 
69
> abc <- function(x, ...) {
67
> abc <- function(x, ...) {
70
+     if (is.null(baseClass(x))) baseClass(x) <- data.class(x)
68
+     if (is.null(oldClass(x))) oldClass(x) <- data.class(x)
71
+     cat("abc: Before dispatching; x="); str(x)
69
+     cat("abc: Before dispatching; x="); str(x)
72
+     UseMethod("abc", x,...) ## UseMethod("abc") (as in S) fails
70
+     UseMethod("abc", x,...) ## UseMethod("abc") (as in S) fails
73
+ }
71
+ }
74
> 
72
> 
75
> abc.default <- function(x, ...) sys.call()
73
> abc.default <- function(x, ...) sys.call()