Coding style 
Author Message
 Coding style

I have inherited support for a great deal of CMS Rexx code which is filled with
statements such as these:

Parse value '0' with newvar
Parse value oldvar1 oldvar2 with newvar1 newvar2

I find these very irritating to deal with.  Is there some advantage to this
construction that I am missing?  As far as I can tell it is nothing
but an obscure, error prone (oldvar1 and oldvar2 had better not contain any
unexpected spaces) and inefficient way to do assignments.



Tue, 06 Feb 2001 03:00:00 GMT  
 Coding style

Quote:

> I have inherited support for a great deal of CMS Rexx code which is
> filled with statements such as these:

> Parse value '0' with newvar
> Parse value oldvar1 oldvar2 with newvar1 newvar2

> I find these very irritating to deal with.  Is there some advantage to
> this construction that I am missing?  As far as I can tell it is
> nothing but an obscure, error prone (oldvar1 and oldvar2 had better
> not contain any unexpected spaces) and inefficient way to do
> assignments.

I agree, on a first pass anyway. I've also seen a fair bit of lists of
ARG VARNAME at the start of programs, and from changing the program I
found no other effect than initialising.

--
Patrick Herring at work ("clearly not" ~ Ed.)
disclaimer ~ "the appearance is BT but the essence is me"
"Ockham's razor is so sharp, I bought the whole argument"



Tue, 06 Feb 2001 03:00:00 GMT  
 Coding style

Quote:
>I have inherited support for a great deal of CMS Rexx code which is filled with
>statements such as these:

>Parse value '0' with newvar
>Parse value oldvar1 oldvar2 with newvar1 newvar2

>I find these very irritating to deal with.  Is there some advantage to this
>construction that I am missing?  As far as I can tell it is nothing
>but an obscure, error prone (oldvar1 and oldvar2 had better not contain any
>unexpected spaces) and inefficient way to do assignments.

It used to be and may still be  (on CMS) that

  Parse value '' with var1 var2 var3 etc

was more efficient to process than multiple assignment statements:

  var1=''
  var2=''
  var3=''
  etc

And for that simple case the meaning isn't too obscure and the code is
easy to change.  Also, something like

  parse value invar 2 with invar .

is an efficient way to set a default (2) invar if invar is null.

Like any other language, REXX has its tricks that come in handy and
make for more efficient code.  In the efficiency vs readability
debate, I'd say that once you know the trick, it isn't any harder to
read (in fact my first example is easier) than multiple statements.

-Doug



Tue, 06 Feb 2001 03:00:00 GMT  
 Coding style


Quote:
>It used to be and may still be  (on CMS) that

>  Parse value '' with var1 var2 var3 etc
>...
>Like any other language, REXX has its tricks that come in handy and
>make for more efficient code.  In the efficiency vs readability
>debate, I'd say that once you know the trick, it isn't any harder to
>read (in fact my first example is easier) than multiple statements.

I now do (almost) all my initialization that way:
  parse value "0 0 0 0 0 0 0 0 0 0 0 0 0 0" with,
        ct.  total  gtotal  .
because adding another variable that needs to be init-zero is dead
easy; ditto for init-empty.


Thu, 08 Feb 2001 03:00:00 GMT  
 Coding style

Quote:



>I now do (almost) all my initialization that way:
>  parse value "0 0 0 0 0 0 0 0 0 0 0 0 0 0" with,
>        ct.  total  gtotal  .
>because adding another variable that needs to be init-zero is dead
>easy; ditto for init-empty.

I used to do this too, but it became error-prone when initializing a bunch
of variables to
the same value (did I specify enough of them?)

When setting a lot of variables to the same value (usually '', '0' or '1'),
I've adopted
the practice of specifying the value only once:
   parse value '' with null 1 array_a. 1 array_b.
   parse value '0' with ct. 1 total 1 gtotal 1 array_a.0 1 array_b.0

To me, it's easier to read. And if I later need to add some more variables,
it's no big deal.

-- Gary Richtmeyer, Tampa, Florida



Thu, 08 Feb 2001 03:00:00 GMT  
 Coding style
But if you have fixed font (eg a 3270) then you can line up the values
with the variable, eg:

parse value 1     2   4    5   7   9    'Joe'   'Cindy' ,
      with  a     b   c    d   e   num9 husband wife    .

and then it is easy to see all the vars and their matched values.

- Doug

On Sun, 23 Aug 1998 18:47:35 -0400, "Gary Richtmeyer"

Quote:




>>I now do (almost) all my initialization that way:
>>  parse value "0 0 0 0 0 0 0 0 0 0 0 0 0 0" with,
>>        ct.  total  gtotal  .
>>because adding another variable that needs to be init-zero is dead
>>easy; ditto for init-empty.

>I used to do this too, but it became error-prone when initializing a bunch
>of variables to
>the same value (did I specify enough of them?)

>When setting a lot of variables to the same value (usually '', '0' or '1'),
>I've adopted
>the practice of specifying the value only once:
>   parse value '' with null 1 array_a. 1 array_b.
>   parse value '0' with ct. 1 total 1 gtotal 1 array_a.0 1 array_b.0

>To me, it's easier to read. And if I later need to add some more variables,
>it's no big deal.

>-- Gary Richtmeyer, Tampa, Florida



Fri, 09 Feb 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Anyone have a good coding style example for coding up FIR FILTER?(EASY METHOD)

2. LTORGs, coding style, etc

3. Smalltalk coding style

4. GACSPLAT :-) Generally Accepted Coding Style (Practiced) Loop Assertion Techniques

5. Coding Style (Was: Julian Day)

6. %% Coding Styles (was lots of threads ....) %%

7. Modular coding style

8. Forth Coding Style

9. Coding Style

10. Dylan coding style & best practices

11. Language Choice and Coding style

12. Modula-2 Coding Style Standard

 

 
Powered by phpBB® Forum Software