Difference between using comment line and blank line.



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Difference between using comment line and blank line.

Postby gokulNmf » Thu Feb 21, 2013 11:00 pm

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.
Cheers,
Gokul
User avatar
gokulNmf
 
Posts: 118
Joined: Sat Mar 28, 2009 6:41 pm
Location: India
Has thanked: 2 times
Been thanked: 0 time

Re: Difference between using comment line and blank line.

Postby Robert Sample » Thu Feb 21, 2013 11:09 pm

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Difference between using comment line and blank line.

Postby c62ap90 » Thu Feb 21, 2013 11:24 pm

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       
      *                                                                 
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 7 times

Re: Difference between using comment line and blank line.

Postby BillyBoyo » Fri Feb 22, 2013 5:48 am

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Difference between using comment line and blank line.

Postby dick scherrer » Fri Feb 22, 2013 11:53 am

The difference is you can add comments in the comment-line but blank-line(s) can only have spaces.

Very good point :)
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Difference between using comment line and blank line.

Postby gokulNmf » Wed Feb 27, 2013 6:14 pm

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.
Cheers,
Gokul
User avatar
gokulNmf
 
Posts: 118
Joined: Sat Mar 28, 2009 6:41 pm
Location: India
Has thanked: 2 times
Been thanked: 0 time

Re: Difference between using comment line and blank line.

Postby BillyBoyo » Wed Feb 27, 2013 6:26 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Difference between using comment line and blank line.

Postby BillyBoyo » Wed Feb 27, 2013 7:38 pm

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).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post