Naming conventions and operators

From: Nils Barth <nbarth_at_fas.harvard.edu>
Date: Sat, 18 Dec 1999 01:56:05 -0500

Hiyas-

In case you don't know me, I'm Nils Barth -- I'm working on
Dr. Genius' documentation and GEL files.

Thanks to some recent additions, Dr. Genius now has about 160
functions. Before it gets too many more, I think we should discuss
(and agree on, hopefully), some naming conventions for functions.

Note that this is the kind of thing that's straightforward to change,
but tedious to check that all instances have been changed. Thus, we'll
be able to change our minds later but we'd rather not.

I see the following as being the basic options:

MixedCase
under_scores
slowcs (that's short lower case, in case you couldn't decipher it)
longlowercase

Some issues to consider (in order of importance, I think):
* Clarity of function names (what does this function do?)
* Low likelihood of clashing with user-defined variables/functions
* Ease of typing them
* Presentation quality

Key note:
In Dr. Genius, it is very easy to assign a new (user-defined) name to
a function. Just set:
fun = function_withVerylongnameindeed
Then fun(x)=function_withVerylongnameindeed(x)

I think this point means we can mostly disregard length/ease of typing
in naming functions, since the user can very easily add abbreviations
(and if they edit the config/rc file, they can make these standard
abbreviations).

Turning to clarity, I think only MixedCase and under_scores indicate
separation of words properly, and are thus the only legible, clear
options. In particular, slowcs is really confusing to me.

Between these, I prefer MixedCase because:
(1) I think it looks nicer -- more professional/legible somehow
(2) It has a low likelihood of clashing with user-defined variables.
That is, if users start all their variables/functions with a lowercase
letter, they will never clash with built-in MixedCase functions.
Also, if they like MixedCase, a nice idea is for users to use
initialLowerCaseMixedCase, which is very similar but will not clash
with built-ins.

By contrast, I see no such easy solution for under_scores -- that is,
we could suggest that all user variables/functions begin with
Upper_case, but this seems to be a pain, since most variables in my
experience are lowercase.

For comparison, what some commercial packages use:
MATLAB, Maple: slowcs
Mathematica, MAGMA: MixedCase

Here is what I suggest:
Use MixedCase with fully spelled out words for functions.
Also include standard abbreviations, such as
sin=Sin
exp=Exponent
e=Exponent(1)
etc.

I think this would fulfill all the above stated goals.
What do y'all think?
Agree? Disagree? Other thoughts/points that I missed?

-- 
  -nils
Received on Fri Dec 17 1999 - 22:55:59 CST

This archive was generated by hypermail 2.2.0 : Sun Apr 17 2011 - 21:00:02 CDT