[R] Dots in function names

Philippe Grosjean phgrosjean at sciviews.org
Sat Oct 1 16:01:18 CEST 2005


Mike Prager wrote:
> on 9/30/2005 2:55 PM Peter Dalgaard said the following:
> 
> 
>>"Mike Prager" <Mike.Prager at noaa.gov> writes:
>> 
>>
>>
>>>Recent R function names seem to be using CaseOfTheLetters to mark words 
>>>rather than dots as was done previously.  Is the use of dots in function 
>>>names deprecated, or is that simply a style choice?  Will function names 
>>>with dots cause problems in future revisions?
>>>   
>>>
>>
>>Well, come the S4 revolution and dots will cause trouble no more...
>>
>>The main reason dots have fallen from grace is that they cause
>>ambiguity in relation to S3 methods. In a nutshell: t.test is not a
>>transpose method for objects of class "test". Since we check S3
>>methods automatically,  it is problematic to keep track of things that
>>look like S3 methods without being so. Check out
>>.make_S3_methods_stop_list() (in the tools package).
>>
> 
> My thanks to Thomas Lumley and Peter Dalgaard for their replies.  Being 
> skeptical about software revolutions, I infer that dots will be of some 
> concern for a long time.
> 
> At the same time, I expect that having names with underscores would 
> limit compatibility with S-PLUS. 
> 
> As a user, I have not encountered problems with dots, and I don't 
> understand whether the concern is likely to apply at the user level.  (I 
> was unable to locate the function that P.D. mentioned above.)  Sorry if 
> this seems dense, but I am not particularly conversant with the 
> internals of R nor experienced in object-oriented programming.
> 
> So while I understand Peter's example showing that dots can be 
> ambiguous, I am still at a loss as to whether that is of real practical 
> concern at a user level; for example, in writing functions that will 
> have limited distribution, or for functions that eventually may be 
> incorporated into an R package.  I am guessing not, but will appreciate 
> more comments if I have that wrong....
> 
> Mike Prager

For sure, for "writing functions that will have limited distribution", 
you can choice the convention that best suits you! Otherwise, the dot in 
functions poses other problems with S3 methods in situations like syntax 
highlighting and automatic code inspection. It is clear that everything 
would have been a lot easier if the dot was *only* used for S3 methods 
constructs. This is not the case. Nobody can change it now, and S4 is 
there that solves the problem in a different way. So, we leave pretty 
well with it until now. No reasons we cannot "survive" with it in the 
future too! ;-)
Best,

Philippe Grosjean




More information about the R-help mailing list