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 signatureI think this may be because the way I wrote the scripts could be deprecated. Indeed I recently upgraded to R-1.7.1 (I compiled it from source). I use R on a RedHat 8.0 system.
This is how my classes look like :
#----------------------------------------------------- # CLASS Person #-----------------------------------------------------
setClass("Person",representation(name="character"));
# CONSTRUCTOR
setMethod("initialize","Person",
function(.Object)
{
[EMAIL PROTECTED] <- "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
[EMAIL PROTECTED] <- dbConnect("MySQL");
[EMAIL PROTECTED] <- "unknown service";
return(.Object);
}
);
The script just creates a new Employee and the error occurs when it comes to callNextMethod() :
> library(RMySQL)
> new("Person")
An object of class "Person"
Slot "name":
[1] "Unknown"
>
> new("Employee")
Error in insertMethod(methods, sig, args, def, TRUE) :
inserting method corresponding to empty signatureAny help would be greatly appreciated. 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 ?
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
