Page 1 of 1

Difference between using comment line and blank line.

PostPosted: Thu Feb 21, 2013 11:00 pm
by gokulNmf
Hi All,
This might look very basic, but please support me.

Is there any difference between a commented line and a blank line in cobol for Zos?

TIA.

Re: Difference between using comment line and blank line.

PostPosted: Thu Feb 21, 2013 11:09 pm
by Robert Sample
From the Enterprise COBOL Language Reference manual:
1.6.5.6 Blank lines




A blank line contains nothing but spaces in column 7 through column 72. A blank line can appear anywhere in a program.

and
1.6.5.2 Comment lines



A comment line is any line with an asterisk (*) or slash (/) in the indicator area (column 7) of the line. The comment can be written anywhere in Area A and Area B of that line, and can consist of any combination of characters from the character set of the computer.

Comment lines can be placed anywhere in a program, method, or class definition. Comment lines placed before the identification division header must follow any control cards (for example, PROCESS or CBL).

Important: Comments intermixed with control cards could nullify some of the control cards and cause them to be diagnosed as errors.

Multiple comment lines are allowed. Each must begin with either an asterisk (*) or a slash (/) in the indicator area.

An asterisk (*) comment line is printed on the next available line in the output listing. The effect can be dependent on the LINECOUNT compiler option. For information about the LINECOUNT compiler option, see LINECOUNT in the Enterprise COBOL Programming Guide. A slash (/) comment line is printed on the first line of the next page, and the current page of the output listing is ejected.

The compiler treats a comment line as documentation, and does not check it syntactically.

so there are differences.

Re: Difference between using comment line and blank line.

PostPosted: Thu Feb 21, 2013 11:24 pm
by c62ap90
The difference is you can add comments in the comment-line but blank-line(s) can only have spaces.

The line after "DATE-COMPILED." is a blank-line.
The line(s) with a asterisk/star/splat in column 7 are comments. Notice the line after "DESCRIPTION" is not blank, but a comment with no text.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7---
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID.    XXXXX.                                             
       AUTHOR.        XXXXXXXXXX.                                       
       INSTALLATION.  FBI IT.             
       DATE-WRITTEN.  MM/DD/CCYY.                                       
       DATE-COMPILED.                                                   
                                                                         
      ***************************************************************** 
      *  DESCRIPTION:  XXXXXXXXXXXXXXXXXXXXXXXXXXXXX                     
      *                                                                 
      *    PROCESS  :  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
      *                XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
      *                XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
      *                XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
      *                                                                 

Re: Difference between using comment line and blank line.

PostPosted: Fri Feb 22, 2013 5:48 am
by BillyBoyo
Gokul,

What is the reason for asking?

Although there are differences, as has been said, I can't think of a way in which the differences would matter to the compile, apart from that little warning about control cards.

Re: Difference between using comment line and blank line.

PostPosted: Fri Feb 22, 2013 11:53 am
by dick scherrer
The difference is you can add comments in the comment-line but blank-line(s) can only have spaces.

Very good point :)

Re: Difference between using comment line and blank line.

PostPosted: Wed Feb 27, 2013 6:14 pm
by gokulNmf
Hi Dick,

One of my co-worker was disputing that the blank will be a overhead to the compilers/Load Modules but the Comment lines won't. so I went through the Ibm documents, i could not get a clear understanding on that. So I put same to forum.

Re: Difference between using comment line and blank line.

PostPosted: Wed Feb 27, 2013 6:26 pm
by BillyBoyo
OK, blank lines or comments have no impact whatsoever on an object/load module.

Since a comment can be identified by looking at one byte, and a blank line only by looking at 64 bytes, there would be "some" difference to the compile time. Depending on how the compiler is written would lead to an indication of how much "some" might be, but given that blank lines are likely a small proportion of your code, I doubt that you'd ever have enough blank lines to make it in any way "worth" changing them to comments. Suggest to your co-worker that they get on with their own work. If they have theories themselves, then they can test them out first, before opening themselves to ridicule.

Re: Difference between using comment line and blank line.

PostPosted: Wed Feb 27, 2013 7:38 pm
by BillyBoyo
For fun, I just compiled a small program with 10,000 blank lines in, and the same with 10,000 comment lines.

The program with blank lines was about 180% slower than the 15-line program to compile. The program with comments about 180% slower to compile than the 15-line program. There may be a difference between the blanks and comments, but with 10,000 of them it is less than one percent.

To estimate it another way, for every 1,000,000 lines/compile that are changed from blank to a comment, the saving will be less than one CPU second, and probably considerably less (the figure for the difference is too small for it to be of genuine use for estimating).