Dear all, First, many thanks to John Chambers, and anyone else who was involved, for the new support for "reference classes" in R 2.12.0. It's nice to see this kind of functionality appear in a relatively R-like form, and with the blessing of the core team. In some contexts it is undoubtedly appealing to associate a set of methods with a class directly, rather than defining a load of generics which are only ever likely to be implemented for a single class, or some other such arrangement. (I was actually in the process of writing a package which did something similar to the reference class idea, although it is less fully realised.)
My initial experiences with this functionality have been very positive. I've stumbled over one minor issue so far: default values of method parameters are not displayed by the help() method, viz. > library(methods) > Regex <- setRefClass("Regex", fields="string", methods=list( + isMatch = function (text, ignoreCase = FALSE) + { + 'Returns a logical vector of the same length as "text", indicating whether or not each element is a match to the regular expression.' + grepl(string, text, ignore.case=ignoreCase, perl=TRUE) + } + )) > Regex$help("isMatch") Call: $isMatch(text, ignoreCase = ) Returns a logical vector of the same length as "text", indicating whether or not each element is a match to the regular expression. It seems unlikely that this is intentional, but correct me if I'm wrong. It still seems to happen with the latest R-patched (Mac OS X 10.5.8). As a suggestion, it would be nice if the accessors() method could be used to create just "getters" or just "setters" for particular fields, although I realise this can be worked around by removing the unwanted methods afterwards. More generally, I was wondering how firm the commitment is to providing this kind of programming mechanism. I know it's likely to change in some ways in future releases, but can I use it in packages, trusting that only a few tweaks will be needed for compatibility with future versions of R, or is it possible that the whole infrastructure will be removed in future? All the best, Jon ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel