[R] problem trying to use a superclass on R-1.7.1

Laurent Faisnel laurent.faisnel at ariase.com
Tue Sep 9 12:49:57 CEST 2003


  Hi dear helpers,

I have been using for quite a long time a script where a class extends 
another one (without trouble). But I now have problems of that kind 
while trying to run the script :

Error in insertMethod(methods, sig, args, def, TRUE) :
         inserting method corresponding to empty signature

I think this may be because the way I wrote the scripts could be 
deprecated. Indeed I recently downloaded R-1.7.1 (binary version).

This is how my classes look like :

#-----------------------------------------------------
# CLASS    Person
#-----------------------------------------------------

setClass("Person",representation(name="character"));

# CONSTRUCTOR

setMethod("initialize","Person",
           function(.Object)
           {
               .Object at name <- "Unknown"; # default name
               return(.Object);
           }
);

#-----------------------------------------------------
# CLASS    Employee           (extends Person)
#-----------------------------------------------------

setClass("Employee",representation("Person", service="character", 
con="MySQLConnection"));

# con : connection to be established with MySQL database

# constructor
setMethod("initialize","Employee",
           function(.Object)
           {
               .Object <- callNextMethod();  # calls the superclass 
constructor
             .Object at con <- dbConnect("MySQL");
             .Object at service <- "unknown service";
             return(.Object);
           }
);

The script just creates a new Employee and the error occurs when it 
comes to callNextMethod()

Thanks for any help.
Laurent

PS : I've read there's something related to this in R-1.7.1's new 
features, but it does not seem to match the problem exactly (problems 
that used to wait until new() is called to appear are now caught 
properly). Is the initialize() function deprecated ? Should I use 
prototype instead ?




More information about the R-help mailing list