[Rd] Questions on version arg to setClass and serialized instances

From: Seth Falcon <sfalcon_at_fhcrc.org>
Date: Fri 21 Apr 2006 - 18:20:10 GMT


I have a few questions and thoughts regarding class versioning and serialized S4 class instances.

How is the version argument to setClass is intended to work? It appears to want an externalptr, but that seems odd to me.

    setClass("FOO", representation(x="numeric"), version="1.2.3")

    Error in validObject(.Object) : invalid class     "classRepresentation" object: invalid object for slot "versionKey"     in class "classRepresentation": got class "character", should be     or extend class "externalptr"

The use case I'm interested in is:

  A user has a serialized instance foo of class FOO in old.rda. The   class definition lives in FooPkg.

  Suppose the class definition of FOO in FooPkg changes. When the   user loads the new version of FooPkg and then loads their old.rda   file, how can the user identify the instance as one belonging to an   old class def version?

Some thoughts:

One more question:

Is there a convenient way to introspect an _instance_? The slotNames() method seems to get data from the class definition and doesn't report the right info for an instance that is out of date w.r.t. to the current class defn (i.e., was deserialized after a class defn update).

Thanks for listening.

+ seth



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Apr 22 04:22:46 2006

This archive was generated by hypermail 2.1.8 : Fri 21 Apr 2006 - 20:18:18 GMT