From maechler at stat.math.ethz.ch  Wed Jun 10 10:35:30 2009
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Wed, 10 Jun 2009 10:35:30 +0200
Subject: [Rd] Inheritance before ANY...
In-Reply-To: <4A2EC207.5070007@u-paris10.fr>
References: <4A2EC207.5070007@u-paris10.fr>
Message-ID: <18991.28754.536164.538648@lynne.math.ethz.ch>

>>>>> "CG" == Christophe Genolini <cgenolin at u-paris10.fr>
>>>>>     on Tue, 09 Jun 2009 22:11:51 +0200 writes:

    CG> Hi all,
    CG> I am programming using S4. I define two classes, "B" is inheriting from 
    CG> "A". Apparently (at least since version 2.9.0 ?), when the correct 
    CG> signature is not find,
    CG> R prefers to chose a signature in the ancestor BEFORE a signature in the 
    CG> class. This is very strange to me...

    CG> If I define plot for ("A",missing) and ("B",ANY), calling 
    CG> plot("B",missing), I would expect R to chose plot("B",ANY) before 
    CG> plot("A",missing)

    CG> ------------------ (translate from french) --------
    CG> Note : method with signature "A#missing" chose for function "plot",
    CG> signature cible "B#missing".
    CG> "B#ANY" could also be compatible

Yes, method dispatch had indirectly been greatly improved
in 2.9.0, as the elimination of duplicate superclasses and a
consistent (superclass) ordering was introduced.

Look at
   ?Methods
and skip to its references (simply "sr" in ESS),
finding

     Chambers, John M.(2009) _Developments in Class Inheritance and
     Method Selection_ <URL:
     http://stat.stanford.edu/~jmc4/classInheritance.pdf>.

which is very recommended, and, BTW, as I just notice, has been
updated in the very last few days,
judging from my earlier reading; the updates include new
features of class definition / method dispatch in the situation
where S3 and S4 are intermingled.

Regards,
Martin Maechler, ETH Zurich



[Rd] Inheritance before ANY...
Martin Maechler