From maechler at stat.math.ethz.ch  Tue Mar 19 17:16:42 2013
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue, 19 Mar 2013 17:16:42 +0100
Subject: [Rd] removing union class
In-Reply-To: <CAHavPHGHnLEZK6oO9t0A6pCocizo1Anqk37EbzrVH5V1ThjqYA@mail.gmail.com>
References: <CAHavPHES4xxZ6+wUXBG54ED8Y3OcOyxrCRUEMhJaB2hsepG3Xw@mail.gmail.com>
	<20802.64086.443586.813352@stat.math.ethz.ch>
	<20802.64898.70553.300100@stat.math.ethz.ch>
	<CAHavPHGHnLEZK6oO9t0A6pCocizo1Anqk37EbzrVH5V1ThjqYA@mail.gmail.com>
Message-ID: <20808.36714.521516.852157@stat.math.ethz.ch>

>>>>> "RG" == Renaud Gaujoux <renaud at mancala.cbio.uct.ac.za>
>>>>>     on Sun, 17 Mar 2013 10:38:44 +0200 writes:

    RG> Late report is better than never isn't it? :)
    >> > Well,... you forgot to show the error (and the
    >> traceback) :
    >> 

    RG> Apologies, I usually include them (and sessionInfo ...).


    >> 
    >> > Note that this problem is somewhat dependent on the use
    >> of the > infamous "matrix" class {not properly defined as
    >> a class in S3, > as it may or may not have dimnames, and
    >> then tried to be made S4 > compatible "as well as
    >> possible" in the methods package, see
    >> 

    RG> Ok. What I want to do is to define a class in my
    RG> namespace that gather some matrix-like classes so that I
    RG> can define a set of common functions for them.
    RG> Initially I want matrix and ExpressionSet objects, and
    RG> possibly add array objects later.  Union classes seem to
    RG> be exactly the way to go, but maybe there is an
    RG> alternative?

There's really *no* problem with class unions.
They work fine and nicely... we also use them in the Matrix
package (part of the R distro).

The problem you've reported is only a propblem of removeClass().

Martin



    >> 
    >> > Of course, I could not have thought of a realistic
    >> situation > where this was a problem, but then you
    >> exemplify one :
    >> 
    >> >> Hadley, this is problematic for devtools, because
    >> load_all tries to cleanup >> S4 classes when an error
    >> occurs when loading a development package and >> crashes
    >> with no hint on the original error.
    >> 
    >> 
    RG> I guess a quick fix for devtools, would be to wrap the
    RG> cleanup procedure into a try or tryCatch (Hadley?).


    RG> Thanks, Renaud



[Rd] removing union class
Martin Maechler