Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: what's in a name? (legal and conventional constructions of identifiers)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119896] Re: what's in a name? (legal and conventional constructions of identifiers)
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Tue, 28 Jun 2011 07:57:04 -0400 (EDT)

I start every variable with a small letter and each subsequent word with a  
capital, as in

thisVariableName

Hence, any variable in my notebooks that starts with a capital is  
built-in, and the others are mine. I don't have to remember which are  
which.

I try to use descriptive names that state the variable's purpose without  
going to more than eight or ten characters. Or I stick to one-letter  
names, when descriptive names don't seem necessary.

I never use Greek, Latin, special characters, or subscripts in variable  
names.

I don't use the letter "l" unless it's part of a word like "list", so that  
I can easily tell that it isn't "1". In this e-mail font they may look  
different, but in other fonts they often do not... or not to old eyes, at  
least.

If you want subscripts and Greek in the display of an equation, you can do  
that WITHOUT using subscripted variables or Greek letters in variable  
names, as in:

Sum[m[i], {i, 10}] == 1 /. m[i_] :> Subscript[\[Mu], i]

There are other ways to do this, but the point is that I don't clutter my  
code with special characters. One advantage is that copy/paste from  
Mathematica to e-mail works smoothly and yields easily readable code  
(mostly).

Bobby

On Mon, 27 Jun 2011 06:32:22 -0500, Alan <alan.isaac at gmail.com> wrote:

>> http://reference.wolfram.com/mathematica/tutorial/BasicObjects.html
>
> Thank you. That provides extra info, which imo should be linked from the  
> DefiningVariables documentation.  I note that it does not define  
> "letter-like form" and still does not warn users not to use underscores  
> in variable names (which is a known common mistake of newcomers).
>
> In terms of my question, it also does not (directly) address the  
> question of convention that I raised. It is often desirable to break  
> names into parts with a special symbol. (E.g., where many languages  
> would use an underscore.) I'm guessing from what I've seen that users  
> most often introduce symbols of the form prta$prtb. An alternative  
> practice (that I actually have not seen in use, but I'm a neophyte)  
> would be to use contexts: prta`prtb.  I find the latter a bit harder to  
> read as a single name; are there other considerations?
>
> Thanks,
> Alan
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: what's in a name? (legal and conventional constructions of identifiers)
  • Next by Date: How to write a "proper" math document
  • Previous by thread: Re: what's in a name? (legal and conventional constructions of identifiers)
  • Next by thread: Re: Is a conditional evaluation of sections of a notebook possible?