On 19/06/2021 12:23 am, Tom Brennan wrote:
Side track to logic blocks: I like matching up indentations on the do/end instead of if/end.  And the same in C-style languages such as:

  if (something == 10)
   {
    run some stuff;
    run more stuff;
   }

This is referred to as Allman brace style. Although the braces should be matched with the "if". This is common in Microsoft IDEs and is the default for C/C++/C#. I've used it and I like it. The rational is that that you can easily delete "else" blocks as they "else" starts on a new line. I don't use this style anymore.



But almost all code I see in the world (other than my own) does this:

  if (something == 10) {
    run some stuff;
    run more stuff;
  }

This style k&R or the OTBS (One True Brace Style). It's dominant and the default in Java, JavaScript etc.



That just confuses me when I need to match up the brackets or do/end's.

My editor matches the beginning/end scopes just by pressing CNTL+[/]. Slickedit is good in that it has a feature called "Adaptive Formatting" that will adjust the brace/indentatiuon stylesbased upon the file being edited. This is great because I work on lots of code with different styles and it is a sacking of fence to introduce "personal styles" into an established code base.



On 6/18/2021 9:12 AM, Seymour J Metz wrote:
I agree, although if I expect to be adding code in the future then I'll write

    if fx then do
       ntim=ntim+1
       end
    else do
       nres=nres+1
       end

Note that I don't like, and don't use in REXX scripts, the C indentation conventions; I indent END.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3

________________________________________
From: IBM Mainframe Discussion List [[email protected]] on behalf of Bob Bridges [[email protected]]
Sent: Friday, June 18, 2021 11:57 AM
To: [email protected]
Subject: Re: EXTERNAL: Coding for the future

Ack!  To my mind

   if fx then
     do
       ntim=ntim+1
     end
   else
     do
       nres=nres+1
     end

...is much harder to read than

   if fx then ntim=ntim+1
         else nres=nres+1

---
Bob Bridges, [email protected], cell 336 382-7313

/* -from _The Voyage of the Dawn Treader_ by C S Lewis:
Eustace: In our world a star is a huge ball of flaming gas.
Ramandu: Even in your world, my son, that is not what a star is but only
what it is made of. */

-----Original Message-----
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of
Crawford, Robert C.
Sent: Wednesday, June 16, 2021 09:23

It's a small thing, but I now longer try to cram as much code into line as I can.  Now I put spaces between operators and variables and after commas.  I
also put the clauses following "THEN" and "ELSE" on another line.

Oh, and I used to this:
LOOP      MVC   HERE,THERE

And now do this:
LOOP      DS       0H
                 MVC   HERE,THERE

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to