scripting style issue

Robert Brenstein rjb at rz.uni-potsdam.de
Wed Jan 15 05:48:01 EST 2003


I think it is a good idea. I have been considering something like 
that myself after I properly realized that array variables are a 
different kind of beast than normal variables.

I wish that Scott would add functions that allow to list array vars 
-- as I noticed earlier, they are omitted from normal variable lists 
(which I see now making sense).

I normally use g in front of globals and p for parameter names. 
However, in a large multistack project, I found that prefixing them 
with "xxxx$" works better (xxx is the name of the stack). Since some 
of the parallel stacks in this project have similar functionality, 
this allows me to have the same var name (to denote the same type of 
content) but still avoid namespace conflicts. In parallel, I use 
"xxx." for names of local vars. Furthermore, since these stacks share 
some handlers through "stacksinuse", I use similar notation for 
handler names -- those intended for global use start with "xxxx$" and 
those for local use start with "xxxx."

I guess the point is that it is good to have a clear and consitent 
naming style, although no one set of guidelines can work for all 
cases. However, what you propose will be a good starting point for 
many people.

Robert


>  -----Original Message-----
>  From: Richard Gaskin [mailto:ambassador at fourthworld.com]
>  Sent: 14 January 2003 10:13
>  To: MetaCard List; use-revolution at lists.runrev.com
>  Subject: scripting style issue
>
>
>
>  As documented in the Script Style Guide at
>  <http://www.fourthworld.com/embassy/articles/scriptstyle.html>
>  , I'm fairly
>  OCD when it comes to variable names, having adopted the sort of
>  Hungarian-notation-lite that makes dissecting code just a
>  little easier.
>
>  There's an item not addressed in that document that's becoming an
>  ever-bigger part of my scripting: arrays.
>
>  It's useful to denote arrays distinctly because they require different
>  syntax from other variable types.  For example, you can get
>  the value of an
>  arrany element, but you can't get a displayable string from the array
>  itself.
>
>  For a long time I just added the word "Array" to the end of a
>  variable name
>  as a reminder, like "gMyOpenWindowsArray".  As I use arrays
>  more and more, I
>  simply don't want to type that much, any more than I would type
>  "globalMyOpenWindows"
>
>  In recent weeks I've started adding an "a" after the type
>  specifier as a
>  shorter, arguably clearer, notation:
>
>    string form:  gMyOpenWindows
>    array form:   gaMyOpenWindows
>
>  With script-locals being:
>
>    string form:  sMyOpenWindows
>    array form:   saMyOpenWindows
>
>  Parameters:
>
>    string form:  pMyOpenWindows
>    array form:   paMyOpenWindows
>
>  ...etc.
>
>  While I've enjoyed this in my own scripting, I recognize
>  there's a fine line
>  between adding specificity and making things cumbersome.
>
>  So three questions:
>
>  1. Does this convention seem useful? Specifically, should I
>  bother adding it
>  to the Script Style Guide?
>
>  2. How do you denote arrays?
>
>  3. Is this boring?
>
>  --
>   Richard Gaskin
>   Fourth World Media Corporation
>   Developer of WebMerge 2.1: Publish any database on any site
>   ___________________________________________________________
>   Ambassador at FourthWorld.com       http://www.FourthWorld.com
>   Tel: 323-225-3717                       AIM: FourthWorldInc
>



More information about the metacard mailing list