gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] Fixed vs Free Format


From: Brian Tiffin
Subject: Re: [open-cobol-list] Fixed vs Free Format
Date: Thu, 17 Nov 2011 17:35:09 -0500
User-agent: Opera Mail/11.52 (Linux)

On Thu, 17 Nov 2011 16:12:07 -0500, Andrew Pennebaker <address@hidden> wrote:

Honest questions from a newbie:

   - Does free format allow arbitrarily indented code like Ruby, or
consistent indentation like Python, or farthest indentation like Haskell?

Arbitrary.

   - Does free format allow extra whitespace?

Yep. By standard, FIXED form is converted to FREE form during preprocessing. Try running various sources through cobc -E to see. If I remember correctly, we are only limited by an internal 2048 character line buffer.


Can we subsume fixed format into free and have the compiler
*encourage*people to use free but never complain when we code in
fixed?

I would say no to that one.  From the Draft standard

  6
  Reference format
  6.1
  General
Reference format specifies the conventions for writing COBOL source text and library text. COBOL provides two reference formats: free-form reference format and fixed-form reference format. The two types of reference format may be mixed within and between source text and library text by use of SOURCE FORMAT compiler directives. The
  default reference format of a compilation group is fixed-form.

By standard, default format is fixed-form. And I would NOT encourage people to use free form. Personal preference is always allowed but spec calls for FIXED default.

If you'd like a compiler for personal use, look to cobc/cobc.h and swap the 0 and 1 on CB_FORMAT_FREE and CB_FORMAT_FIXED. For me, making changes to the sources and building a personal compiler is wicked cool and feels manly. ;)

In reality, it might be better to just

$ alias cobc='cobc -free'

But if I had to maintain any code I'd still like to see OCOBOL >>SOURCE FORMAT IS FREE on line 1 if that was the intent. (the OCOBOL is just a personal sequence number preference of mine). And line one should ALWAYS be coded to FIXED form rules in my opinion. A few simple tricks and FIXED form sources will compile -free.


Whitespace is a good way to visually separate components of a larger
system. Since code proceeds line by line, vertical whitespace is a powerful
way to make code more readable. Horizontal whitespace in the form of tabs
and spaces helps to indicate nested blocks of code. I agree that whitespace
makes code much more readable.

However, requiring seven spaces before each line of code is just silly.

I'll disagree. :) I might be biased, but the FIXED form samples in the OC FAQ seem pretty reasonable to me, and I'd say readable. Even the single sentence procedure division in ocdoc.cob http://opencobol.add1tocobol.com/#what-is-ocdoc seems, to me, to be quickly grokable.


It
adds no whitespace; it just shifts all code over. You might as well drag a text editor window over to the right; it's aesthetically identical and adds
just as much "readability". I realize the historicity of the extra
characters, but tradition /= good practice. We have text editors to show
line numbers, so we don't need that column any more.

Perhaps not need, but it's there and a LOT of existent shops that use the sequence number area for sanity control over large masses of source code.


There is indeed the potential for breaking backwards compatibility, and for alienation of people who prefer the spurious spaces. But computers exist to automate; there's no technological reason that OpenCobol can't read a .cob file, decide for itself which format is being used, fixed or free, and run
with it. One solution is to read the first line: If there are six spaces
and a star, consider the file to be in fixed format. If there are no
spaces, consider the file to be in free format. Or you could go so far as
statistical analysis to determine which format is being used more often in
a file, and inform the coder of the exceptions. There are myriad ways to
make fixed and free coders happy, all without requiring flags or setting
defaults.

Harder than it may look. Peruse cobc/pplex.l for some hints on how weird the guessing game would be.

I'm a FIXED fellow by nature, but code to both forms. I'm already super happy with the flexibility in OpenCOBOL.


Cheers,

Andrew Pennebaker
www.yellosoft.us

Cheers,
Brian


On Thu, Nov 17, 2011 at 3:48 PM, john Culleton <address@hidden>wrote:

On Thu, 17 Nov 2011 15:42:24 -0500
Andrew Pennebaker <address@hidden> wrote:

> Can -free be the default in future versions?
>
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.
I prefer fixed as the default. COBOL is designed to be readable.
The fixed format aids in that.

--
John Culleton
Free list of books for self-publishers:
http://wexfordpress.net/shortlist.html

"Create Book Covers with Scribus"
http://www.booklocker.com/books/4055.html


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list


reply via email to

[Prev in Thread] Current Thread [Next in Thread]