[R] checking generic/method consistency

Thomas Lumley tlumley at u.washington.edu
Fri Sep 26 19:10:18 CEST 2003


On Fri, 26 Sep 2003, Simon Fear wrote:

> > -----Original Message-----
> > From: Henrik Bengtsson [mailto:hb at maths.lth.se]
> > Sent: 26 September 2003 16:43
>
> <snip>
> > ... the intention
> > is to find a style that avoid problems like yours, where it says that
> > you should avoid periods in function names except if you use it for S3
> > class methods. Feedback is appreciated.
>
> One possible argument against this is the fact that 851 of the 1655
> objects in base use a period in their name.
>
> OK, well, not really that many because this list includes a lot of bona
> fide S3 class methods - but it also includes sys.*, unix.*, win.* and
> that's
> not
> to mention data.frame (which is of course NOT a method of the
> function data). And help.start. Then there is read.* which is to some
> extent S3-class-like in that the read method is set by .* but it is
> called explicitly, rather than according to the class of the first
> argument.
>
> So, I don't see universal support for  your .* proposal ... and I'm
> certainly
> not going to rewrite my old code...
>

Old code is precisely the issue.

Newly added functions in base typically don't have . in their name, so we
have eg

socketSelect
constrOptim
textConnection
tryCatch
summaryRprof
compareVersion
extractAIC

and in R1.8.0 print.coefmat is being removed and replaced by printCoefmat
(though some people obivously never learn, since capture.output() was
added as recently as 1.7.0)

The problem is that many of the functions in base are either widely used
or part of the S language definition or both, and so can't be removed.
read.table, data.frame and the sys.* functions are good examples.

On the other hand, with either S4 methods or namespaces you have to
declare which functions are methods, so the scope for confusion is
getting smaller.   Also, in the near future we will have the underscore
back as an ordinary character and can use it as a word separator in
function names.


	-thomas




More information about the R-help mailing list