Rev 6236 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
R : Copyright 1999, The R Development Core TeamVersion 0.90.0 Under development (unstable) (October 22, 1999)R is free software and comes with ABSOLUTELY NO WARRANTY.You are welcome to redistribute it under certain conditions.Type "?license" or "?licence" for distribution details.R is a collaborative project with many contributors.Type "?contributors" for a list.Type "demo()" for some demos, "help()" for on-line help, or"help.start()" for a HTML browser interface to help.Type "q()" to quit R.> ### Using Method Dispatch on "mode" etc :>> abc <- function(x, ...) {+ if (is.null(class(x))) class(x) <- data.class(x)+ cat("abc: Before dispatching; x="); str(x)+ UseMethod("abc", x,...) ## UseMethod("abc") (as in S) fails+ }>> abc.default <- function(x, ...) sys.call()>> "abc.(" <- function(x)+ cat("'(' method of abc:", deparse(sys.call(sys.parent())),"\n")> abc.expression <- function(x)+ cat("'expression' method of abc:", deparse(sys.call(sys.parent())),"\n")>> abc(1)abc: Before dispatching; x=Class 'numeric' num 1abc.default(1)> e0 <- expression((x))> e1 <- expression(sin(x))> abc(e0)abc: Before dispatching; x=Class 'expression' expression((x))'expression' method of abc: abc.expression(e0)> abc(e1)abc: Before dispatching; x=Class 'expression' expression(sin(x))'expression' method of abc: abc.expression(e1)> abc(e0[[1]])abc: Before dispatching; x=Class '(' language, mode "(": ( x'(' method of abc: abc.((e0[[1]])> abc(e1[[1]])abc: Before dispatching; x=Class 'call' language sin(x)abc.default(e1[[1]])>