I've made some changes (in bold) following your comments :

# class definition :
setClass("MyClass", representation(mynumber="numeric"));

# the initilization method :
setMethod("initialize","MyClass",
         function(.Object)
         {
           .Object@mynumber <- 10;
           return(.Object);
         }
);

# defining the generic function  generates a warning message (already 
generic function)- but everything works fine without it - so it seems 
better not to use it
*setGeneric("perform", function(object) standardGeneric("perform"));
*
# the perform method definition - this alone seems sufficient for me, 
and S4-looking
*setMethod("perform","MyClass",**
         function(object) {
           object@mynumber <- object@mynumber + 10;
           return(object);
         } **);*
  
 I replaced my unlucky /.Object/ by /object/ but for method initialize.
The execution of my program used to begin with an output like :

Creating a new generic function for "perform"

With the setMethod only, there is not this output any longer. Does this 
mean that the execution becomes faster ?

Thank you for your fast and useful answers. I've found an interesting R 
help page I had never seen before at 
http://www.maths.lth.se/help/R/S3toS4 which gives additionnal 
information about S3 and S4 classes.

Regards,
Laurent

<http://www.maths.lth.se/help/R/S3toS4/>

	[[alternative HTML version deleted]]


