Skip to content
Prev 39221 / 63424 Next

Avoiding name clashes: opinion on best practice naming conventions

On 11-02-16 4:29 AM, Janko Thyson wrote:
Another verbose solution is to use descriptive names for your functions. 
  Then you'll only clash with functions that are trying to do the same 
thing.
Is it really a problem when developing?  Surely you can control which 
other packages are loaded, and just choose names that don't clash with 
those?  The real problem with name clashes comes when your package is 
out in the wild, and a user wants to use your package and an unrelated 
one at the same time.  If you both have a foo() function that user's 
scripts could change depending on the search order.
You should definitely do this.  Functions which are not exported will 
not be visible to other packages without a prefix, so they won't clash. 
  Your package will be guaranteed to see its own functions first.  A 
user can still have a clash between your exported functions and some 
other package's exports, but with fewer functions exported, that will 
not be as much of a problem.

Duncan Murdoch