For arithmetic operators, the most elegant way often is to define so called `group methods' for the whole group of arithmetic operators.
This actually applies also applies to the old classes and methods. One example where we do this is the 'Matrix' package, see the source, e.g., in https://svn.r-project.org/R-packages/Matrix/R/dMatrix.R Note that for a namespaced package, on also needs to import the group generics from the 'methods' package in NAMESPACE: ## Currently, group generics need to be explicitly imported: importFrom("methods", Arith, Compare, Math, Math2, Summary, Complex) Martin Maechler, ETH Zurich >>>>> "Iago" == Iago Mosqueira <[EMAIL PROTECTED]> >>>>> on Tue, 14 Jun 2005 09:23:40 +0200 writes: Iago> Dear all, Iago> I need to re-define some mathematical operators (+, *, /, etc) for an S4 Iago> class based on array. All references I have found (S Programming, Green Iago> Book) show how to define S3 methods for this (like in page 89 of S Iago> Programming for "-.polynomial"). What is the preferred S4 way for doing Iago> this? I hope I haven't missed some obvious piece of documentation. Iago> Many thanks, Iago> Iago Mosqueira Iago> ______________________________________________ Iago> R-devel@r-project.org mailing list Iago> https://stat.ethz.ch/mailman/listinfo/r-devel ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel