[Rd] signature() and setMethod() problems

From: Robin Hankin <r.hankin_at_noc.soton.ac.uk>
Date: Thu, 28 Jun 2007 13:38:32 +0100

I am having difficulty using signature().

I have one virtual class (onion) and
two nonvirtual classes (quaternion and octonion). containing onion.

I want to define three distinct sets of
arithmetic operations: one for onion-onion, one for onion-real, and one for real-onion [this is more computationally efficient than
coercing reals to onions and then using onion-onion operations].

Executing the following code gives an error [R-2.5.0] at the first call to setMethod():

Error in match.call(fun, fcall) : unused argument(s) (o1 = "onion", o2 = "onion")

Why is this, and what would the List suggest is Best Practice here?


          representation = "VIRTUAL"

          representation = representation(x="matrix"),
          prototype      = list(x=matrix(numeric(),0,4)),
          contains       = "onion"

          representation = representation(x="matrix"),
          prototype      = list(x=matrix(numeric(),0,8)),
          contains       = "onion"

".onion.onion.arith" <- function(o1,o2){stop("OO not implemented")}
".onion.real.arith" <- function(o,r){stop("OR not implemented")}
".real.onion.arith" <- function(r,o){stop("RO not implemented")}

setMethod("Arith", signature 
(o1="onion",o2="onion" ), .onion.onion.arith)
setMethod("Arith", signature(o="onion",r="ANY" ), .onion.real.arith)
setMethod("Arith", signature(r="ANY",o="onion" ), .real.onion.arith)

Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

R-devel_at_r-project.org mailing list
Received on Thu 28 Jun 2007 - 12:43:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 28 Jun 2007 - 15:05:51 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.