Byron Ellis
2006-Dec-11 19:55 UTC
[Rd] Wondering about methods (selecting a less specialized method)
Hi All, I find myself wondering if there is a canonical means of achieving the multiple-dispatch version of 'super'? Specifically, I have a set of classes A, B, X and Y where B extends A and a method Foo with the signature (X,A,Y) and I'd like to implement Foo with the signature (X,B,Y) such that it calls Foo_(X,A,Y) and then does "other stuff." This gets a bit complicated with multiple inheritance but at the moment the best I can think to do is an explicit call to selectMethod.
Seth Falcon
2006-Dec-11 22:38 UTC
[Rd] Wondering about methods (selecting a less specialized method)
"Byron Ellis" <ellis at stat.harvard.edu> writes:> Hi All, > > I find myself wondering if there is a canonical means of achieving the > multiple-dispatch version of 'super'? Specifically, I have a set of > classes > > A, B, X and Y where B extends A > > and a method Foo with the signature (X,A,Y) and I'd like to implement > Foo with the signature (X,B,Y) such that it calls Foo_(X,A,Y) and then > does "other stuff." This gets a bit complicated with multiple > inheritance but at the moment the best I can think to do is an > explicit call to selectMethod.I would expect callNextMethod to work in most cases. Have you tried that? setMethod("Foo", c("X", "B", "Y"), function(x, b, y) { ans <- callNextMethod() ## more }) + seth