[Rd] Unexplained strange behaviour of callNextMethod in S4 methods

From: Harold Petithomme <harold.petithomme_at_meteo.fr>
Date: Mon, 04 Oct 2010 12:49:18 +0200

Hello all.

A few days ago, I submitted a problem which remains unsolved although somebody answered to my question. I still have the problem. Can someone please explain if something is wrong ?

Have a look at this example:

setGeneric("f",valueClass="NULL",def=function(x) standardGeneric("f"))

setMethod("f",signature(x="A"),def=function(x)
{

    a = x_at_a
    cat("nombre :",a,"\n")
}
)

setMethod("f",signature(x="B"),def=function(x)
{

    cat("mot :",x_at_b,"\n")
    callNextMethod()
}
)

a = new("A",a=1)
b = new("B",b="hello",a)

f(a)
f(b)

This last command (f(b)) fails. But remove the 'valueClass="NULL"' setting in setGeneric or add argument x to the call to callNextMethod and it will be OK! Isn't it tricky?

Thanks in advance for any help.

Harold

-- 
*********************************************************
Harold PETITHOMME
Equipe Données et Outils de Prévision (DPREVI/COMPAS/DOP)

Météo France - Direction de la Production
42, avenue G. Coriolis.
31057 Toulouse Cedex
France

Tel : (33/0)5.61.07.82.85
Fax : (33/0)5.61.07.86.09
E-mail : harold.petithomme_at_meteo.fr

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Mon 04 Oct 2010 - 10:37:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 04 Oct 2010 - 13:00:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive