Re: What characters are allowed in mathematica variable names? i.e. how
- To: mathgroup at smc.vnet.net
- Subject: [mg126107] Re: What characters are allowed in mathematica variable names? i.e. how
- From: Jesse Perla <jesseperla at gmail.com>
- Date: Wed, 18 Apr 2012 03:53:11 -0400 (EDT)
- Delivered-to: email@example.com
- References: <firstname.lastname@example.org>
On Monday, April 16, 2012 6:10:20 AM UTC-4, David Bailey wrote: > On 13/04/2012 10:00, Jesse Perla wrote: > Even is you like your program to be stored in a clear test .m file, do > you realise that you can edit these in Mathematica, much as if they were > a notebook, and the result will save back as a .m file. It is even > possible to add headings, sub headings and text cells to your code. > These are hidden as comments in the .m file! Probably notebooks should > have been organised in this way! Actually, I like debugging in the FrontEnd or workbench (or at least editing .m files as the binary notebook files do not play nice with SVN, diffs, separating code with output, or having multiple people working on the same code base). As long as there are no escaped characters in variable names, the code is reasonably easy to read in both text and diff form. As people seem to wonder why me (and likely others) need to run command-line, let me give some context to the issue: I need to run both on Windows FrontEnd and linux command-line as my problem is too time consuming to run on my desktop. The issue is that he job/batch mode of clusters is the way they force everyone to submit jobs so that they can schedule when and where they are run, which makes any hope of using a live session in a notebook impossible. Another issue is that every cluster has elaborate multi-level ssh security methods which make it difficult/impossible to connect directly wit h the FrontEnd. Sorry if I overstated the hypothetical of not using the FrontEnd, I just wanted to filter out comments on how I shouldn't be using command-line or reading clear-text files. Thanks for all of the responses. It is a matter of taste, but it to summarize people's answers to my questions: * You can use a $, as in "my$variable". But you need to be extremely careful with Mathematica symbols and name mangling, in particular it is very dangerous to use numbers such as "my$12" * camelCase is always an option of course, but besides the aesthetics reasons (many find them more difficult to read), you need to be very careful with capitalized letters for the first character as they can clash with mathematica symbols. This is an issue if you are trying to transcribe a lot of math faithfully in the standard notation of your discipline (e.g. "x" for anelement of a set, and "X" for the set itself. Or "x" for the log of a variable, and "X" for the variable in levels). * I originally had used the "`" symbol, which is also used for scoping. e.g "my`variable". I figured it couldn't really hurt, even if it was also used for scoping/namespaces. Don't do this, as the subtle changes in scoping seemed to math other coding difficult. In particular, I ran into a problem when I tried to store out all globals with DumpSave.