Function naming (clash, convention)


#1

I’m reviewing a package and there is a function called VaR (Value-at-risk).

Acc. to the conventions I’d propose to make it all lowercase. But then var clashes with the Base.var function and gives a warning when calling the function. What are my options now?

Iiuc I cannot use (and export) var in a user package without having warnings. The name VaR seems too much non-standard. Using qualified calls, MyPkg.var, would be an option. Import ‘var’ and redefine it would be another option (but I think it’s not a good idea to redefine functions with a completely different behaviour?). I suppose, using a non-abbreviated name, e.g. value_at_risk, would be the best choice.

Opinions? What are you doing in such a situation? I think it should be quite common that short abbreviated function names clash with names in Base (or, less bad, other packages).


#2

Don’t export this name and use YourPkg.var. This is exactly the solution that we’ve settled on for things like gradient and parse.


#3

To throw my two cents in, I think @johnmyleswhite’s suggestion is the way to go if you’re intent on keeping the name var or if var really is the most descriptive name for your function. In your case, value_at_risk seems to be a much more descriptive name that doesn’t conflict with anything in Base. Using descriptive names usually the best way to go. Unless var is standard terminology in your field.


#4

Call the function valueatrisk?