i'm answering my own question: 

1.  setGeneric's override (wipe out, really) previous ones.  (this is
pointed out in section 5.3 of "A (Not So) Short Introduction to S4
Object Oriented Programming in R" by Christophe Genolini.)

2.  the *names* of the formals are important.

3.  one can specify a method that takes a subset of the formals declared
in the setGeneric.

so, in my example, changing "me" to "b1" in A's bB(), allows A to use
B's setGeneric().

for completeness, below is my code that works (or, seems to!).

if anyone knows, in #3 above, how A can specify that "no b2 is
allowed!", i'd be curious.

cheers, Greg Minshall
----
setClass("A",
         representation(
           x="numeric"));

setMethod(
  f="initialize",
  signature="A",
  definition=function(.Object) {
    .Object@x <- 23;
    return(.Object)
  });

setGeneric("bB", function(me) standardGeneric("bB"));
setMethod(
  "bB",
  signature("A"),
  definition=function(b1) {
    return (new("B", b1@x))});

setClass("B", representation(
  bx="numeric"));

setMethod(
  "initialize",
  signature("B"),
  definition=function(.Object, x) {
    .Object@bx <- x;
    return(.Object);
  });

setGeneric("bB", function(b1, b2) standardGeneric("bB"));
setMethod(
  "bB",
  signature("B", "B"),
  definition=function(b1, b2) {
    return(new("B", min(b1@bx, b2@bx)))});

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to