From i.ucar86 at gmail.com  Fri Sep 22 14:44:48 2017
From: i.ucar86 at gmail.com (=?UTF-8?B?ScOxYWtpIMOaY2Fy?=)
Date: Fri, 22 Sep 2017 14:44:48 +0200
Subject: [Rd] S4 method implementation for S3 class
Message-ID: <CALEXWq2Pfutuh1Na5cUaopUyup7WYPddd2HYKBhYGdxesabm0A@mail.gmail.com>

Hi all,

I'm trying to implement the matrix multiplication operator, which is
S4 generic, for an old-style S3 class. The following works as
expected:

x <- 1:10
class(x) <- "myClass"

setOldClass("myClass")
setGeneric("myMethod", function(x, y) standardGeneric("myMethod"))
setMethod("myMethod", c("myClass", "myClass"), function(x, y)
message("dispatched!"))

myMethod(x, x)
#> dispatched!

but I don't understand why the following won't:

setMethod("%*%", c("myClass", "myClass"), function(x, y) message("dispatched!"))

x %*% x
#>      [,1]
#> [1,]  385

Is this approach wrong?

Regards,
I?aki



[Rd] S4 method implementation for S3 class
=?UTF-8?B?ScOxYWtpIMOaY2Fy?=