Re: [Rd] group generics

From: John Chambers <jmc_at_r-project.org>
Date: Thu, 03 Dec 2009 14:25:17 -0800

I missed the earlier round of this discussion and only am commenting now to say that this doesn't seem weird at all, if I understand what you're trying to do.

Martin's basic suggestion,

v <- callGeneric(e1, as(e2, "A"))

seems the simplest solution.

You just want to make another call to the actual generic function, with new arguments, and let method selection take place. In fact, it's pretty much the standard way to use group generics.

John

Ross Boylan wrote:
> Thanks for your help. I had two concerns about using as: that it would
> impose some overhead, and that it would require me to code an explicit
> conversion function. I see now that the latter is not true; I don't
> know if the overhead makes much difference.
>
> On Thu, 2009-12-03 at 13:00 -0800, Martin Morgan wrote:
>
>> setMethod("Arith", signature(e1="numeric", e2="B"), function(e1, e2) {
>> new("B", xb=e1*e2_at_xb, callGeneric(e1, as(e2, "A")))
>> })
>>
>
> Things were getting too weird, so I punted and used explicitly named
> function calls for the multiplication operation that was causing
> trouble.
>
> Ross
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 03 Dec 2009 - 22:26:59 GMT

This archive was generated by hypermail 2.2.0 : Thu 03 Dec 2009 - 23:21:04 GMT