(a new thread, on purpose) >>>>> "RobG" == Robert Gentleman <rgent...@fhcrc.org> >>>>> on Mon, 27 Jul 2009 16:55:50 -0700 writes:
RobG> Hi, I just committed a change to R-devel so that if RobG> debug is called on an S3 generic function, all methods RobG> will also automatically have debug turned on for them RobG> (if they are dispatched to from the generic). very nice. RobG> I hope to be able to extend this to S4 and a few RobG> other cases that are currently not being handled over RobG> the next few weeks. that (S4) will be very useful for me, thank you in advance, Robert! A somewhat related issue: As many of the R-devel readers will know, there has been quite a nice ongoing effort to make S3 and S4 methods and classes more compatible. One issue here, notably for inexperienced programmeRs, is also the fact that methods(f) only tells about S3-methods for 'f', and showMethods(f) only mentions S4 ones. This is not at all design error, as indeed S3 and S4 dispatch is quite different (notably as the latter allows multiple dispatch and hence uses the nice concept of "signature"), used to be more incompatible and, indeed, methods(f) *still* warns, often wrongly, if it finds that f is a (S4) generic function. As this is an RFC, let me just make a few more propositional points, and we (R core) will be happy to receive constructive feedback from outside the core team as well. Propositions / Ideas : [ Using the example of having Matrix: library(Matrix) ] 1) methods(f) should become a bit smarter when it sees that f is an S4 generic, and not say, e.g., for > methods(qr) ... 'qr' is a formal generic function; S3 methods will not likely be found ... but rather at least "look" to see if there's an "ANY" method containing UseMethod() (*1), 2) and if there is, or maybe in any case, methods() should then also call showMethods() to show the S4 methods; or it would suggest the to user to call 'showMethods(..)' 3) showMethods(.) : It could/should a) look for S3 dispatch symptoms such as UseMethod(.) in its "ANY" methods b) call methods() in any case and then possibly mention the result of methods() in any case, *plus* ... that's probably the most difficult part ... warn if there are S3 methods {as per 'b)'} that seem not be called at all {as per a)}, but that would also have to consider .Primitive s with C internal (S3 and S4) dispatch. As you see, these are partly concrete proposals, partly just ideas, asking for feedback, from you, experienced programmeRs, ... Martin Maechler, ETH Zurich --- *1) as there will always be if the S4 methods have been setup properly and *after* the S3 ones. This will typically be the case for situations when there are old traditional S3 methods in "base R", and a package adds new modern S4 methods. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel