Or you could use E=:^1. and, C=: 299792458 would not be too bad either. Or you could decide that your audience would be better served with a bit of introductory text about the purpose of your code. Depending on the field you are working in, some particular capitalizations of letters can be heavily emphasized. But note, also that other people with differing backgrounds might be used to different conventions (for example, maybe r instead of a0 for bhor radius).
Anyways, the advantage of the naming convention is that it helps people discover meanings (specifically: grammar) while reading code. If it's reasonable to believe that they should know those meanings ahead of time, you don't need the convention. The examples you gave, of how you would use the convention, strike me as rather bad examples. I can't help you with those other hypothetical conventions, nor do I understand whatever goals they might have had, but I can try to emphasize the point of this one. Ultimately, the consequences of however you choose to write will be an issue between yourself and your audience. The rest of us do not matter very much unless we are an important part of your audience. -- Raul On Thu, Jan 19, 2012 at 7:37 PM, Viktor Cerovski <viktor.cerov...@gmail.com> wrote: > > > Devon McCormick wrote: >> >> The short answer is: don't do that. >> >> If you want to use single letter names for throw-away, local temp >> variables, that's fine but the point of a global is that it has some >> importance and ubiquity. >> > Maybe the definition I gave previously > e=:1x1 > > has neither importance nor ubiquity for many a reader, who would > upon reading a program with such a global definition be appalled by > such an obvious lack of style. But is any of that really relevant? > Shouldn't there be required a minimum of reading comprehension > that reader of a program knows at least what constitutes a valid > identifier? There are also comments to help out: > > c=:299792458 NB. m/s (the speed of light) > a0=:0.53 NB. Ang (Bohr radius) > > Call me old fashioned, but I really like, now when computers > know about the difference between small and capital letters, to be > able to use say c3 for, well, yes, the third coefficient, and A for, > indeed, matrix A. Let me go on some more: f for a function and > f1 for f"1 that just happens to pop up as often as f. Or maybe > a different version of the same function, just optimized for > a particular case of use? Or maybe my imagination is so poor > that I can't think of any more readable way to write: > f0`f1`f2`f3@.g > > This is not to say that I would forbid programmers from using > something more descriptive for their temps and globals, like: > > SPEEDOFLIGHT=:299792458 > > or, if that constant happens to be very frequent in the program, > so programmer got tired of pressing Ctrl+N every so often, > her eyes getting sore of all these capitals seeking attention, > something shorter, informative, and more stylish like: > > SPOFL=:299792458 NB. c =299792458 m/s > > > >> I'm a big fan of terseness - e.g. >> http://www.jsoftware.com/jwiki/NYCJUG/2009-08-11#TerserisBetter - but >> would >> it really kill you to add a letter or two? Not to mention the extra >> difficulty of searching for single-letter names... >> > Except that the question at stakes is not that of whether terse is > better or not, but the one of style of naming things, where the > greatest achievement so far was the realization that it is universally > open ended. > > Here are my favorite examples where naming conventions > were enforced by the language to achieve something useful: > > 1) Implicit typing in FORTRAN: variables starting with I, J, K are ints, > etc, > 2) Capital letters for free variables in PROLOG, > 3) First capital letter for type identifiers in Haskell, > 4) use of ' in identifier names, like f' or f'1 in Haskell. > > Some informal popular naming schemes: > > 1) Identifiers starting and ending with * in LISP for global/special vars. > > 2) One gaining followers is myFunc or myProc naming convention, > although there is a school of thought that prefers my_func or > my_proc, respectively. > > 3) ALLCAPITALS (or was it ALL_CAPITALS?) for global constants in C. > > I don't have to especially emphasize that J, when it comes to notation, > is all fun. To the example that Tracy mentioned attributing it to Jose: > o =: @ > > I can only retort with: > O =: @: > > There is also km's > o =: +/ . * > > Here are some more fun examples: > plus=:+ > Insert=:/ > Row=:"1 > > Now, +/"1 can be written as > > plus Insert Row > > or defined as: > > plusInsertRow =: plus Insert Row > > or alternatively as: > > sum =: plus Insert > > sumRow =: sum Row > > > >> On Thu, Jan 19, 2012 at 9:50 AM, Viktor Cerovski >> <viktor.cerov...@gmail.com>wrote: >> >>> >>> >>> Raul Miller-4 wrote: >>> > >>> > I wrote up a wiki essay (or perhaps a rant) on some issues that come >>> > up in the context of parsing J: >>> > http://www.jsoftware.com/jwiki/Raul%20Miller/ParsingJ >>> > >>> > My suggestions there may not be ideal, but I sort of like them. >>> > >>> > -- >>> > Raul >>> > ---------------------------------------------------------------------- >>> > For information about J forums see http://www.jsoftware.com/forums.htm >>> > >>> > >>> Leaving the question of style aside, there is one formal problem >>> with the convention: how would one interpret names consisting of >>> a single capital letter (with or without trailing numbers): as nouns >>> or adverbs? Both naming schemes make sense. For instance: >>> >>> I =: 1 >>> I1 =: /("1) >>> I2 =: /("2) >>> E =: &.> >>> >>> Also, some might prefer additionally to have something like: >>> >>> e=:1x1 >>> >>> etc. >>> -- >>> View this message in context: >>> http://old.nabble.com/wiki-essay-tp33157128s24193p33168317.html >>> Sent from the J Programming mailing list archive at Nabble.com. >>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >>> >> >> >> >> -- >> Devon McCormick, CFA >> ^me^ at acm. >> org is my >> preferred e-mail >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> >> > > -- > View this message in context: > http://old.nabble.com/wiki-essay-tp33157128s24193p33171648.html > Sent from the J Programming mailing list archive at Nabble.com. > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm