Kien,
if you want to add variables in a function definition that is predefined by a
Generic and calls CallNextMethod you have to add the '?' argument as
well.
> setMethod("do",signature(a="Achild"),
> function(a,msg,...) {
> print("do Achild")
> callNextMethod()
> })
Best
Simon
On Sep 19, 2013, at 8:58 AM, Ki?n Ki?u <kien.kieu at jouy.inra.fr> wrote:
> Hi,
>
> I met a problem when invoking callNextMethod within a method associated
with a generic function taking ... as an argument.
>
> Here is the code
>
>
setClass("Aparent",representation(x="numeric",y="numeric"))
> setClass("Achild",contains="Aparent")
>
> setGeneric("do",def=function(a,...)
standardGeneric("do"))
> setMethod("do",signature(a="Aparent"),
> function(a,msg) {
> print("do Aparent")
> })
> setMethod("do",signature(a="Achild"),
> function(a,msg) {
> print("do Achild")
> callNextMethod()
> })
>
> myA <- new("Achild")
> buf <- do(a=myA) # works
> buf <- do(a=myA,msg="bonjour") # error
>
> The last call yields the following error message:
>
> Error in callNextMethod() :
> in processing 'callNextMethod', found a '...' in the
matched call, but no corresponding '...' argument
>
> which I do not understand. Replacing "..." by "msg" in
setGeneric makes it work. But I don't like this limitation so much (unless I
understand it).
>
> Regards.
>
> Kien
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.