Re: Where are spaces required in COBOL source code?
- From: "Chuck Stevens" <charles.stevens@xxxxxxxxxx>
- Date: Fri, 27 May 2005 10:57:22 -0700
<epc8@xxxxxxxx> wrote in message
news:1117154259.996313.163080@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> The
> compiler ... requires a
> variable name to be separated by at least one space from the
> parentheses enclosing a subscript (or an expression denoting reference
> modification). ...
> 1. Was this ever part of a COBOL standard?
The concept of "separator" as a syntactic element seems to have been
introduced in the '74 standard, and in that standard, a space is allowed but
not required before a left parenthesis. Before the introduction of the term
"separator", it's a bit tough to tell for sure.
I see some indication that a space was required by COBOL-60 and by the '68
standard between the data-name and the leading left paren. I also see some
evidence that the '68 standard prohibited a space between the leading left
paren and the first subscript, and between the last subscript and the
trailing paren.
The basic rules for '85 COBOL dictating where spaces are required are:
after separator periods, commas and semicolons; before an opening quotation
mark that isn't immediately preceded by a left paren; after a closing
quotation mark that isn't immediately followed by a close paren; and before
an opening pseudo-text delimiter.
-Chuck Stevens
> 2. I sometimes find it puzzling that spaces seem to be required around
> certain things in COBOL when I don't expect them to be.
It might be helpful to find out what the expectations are for COBOL by
examining the COBOL standard!
> For example
> after commas (in CALL),
A "separator comma" may appear anywhere a "separator space" may appear, but
a "separator comma" consists of a comma *followed by a space*. If you put a
comma there, expect to put a space after it. But so long as you have at
least one space between the arguments, the compiler should accept it.
> around the colon in reference modification (at
> least in the compilers I've tested)
I don't see any standard requirement that a ("separator") colon be either
preceded or followed by a space in reference modification, and our
implementation certainly doesn't require it. I'd suggest filing a trouble
report.
> and around operators in a COMPUTE
> expression.
Arithmetic operators (+, -, *, /, **) aren't listed among the "separators".
Syntactic elements of the language are separated by "separators".
Note that in COBOL
COMPUTE A = B-C.
means something entirely different from
COMPUTE A = B - C.
which is one of the underlying reasons *failing* to use separator spaces is
generally considered
in COBOL difference between "A-B" and "A - B" in COBOL, which is probably
one of the underlying reasons *failing* to use separator spaces is
considered Bad Form in COBOL. your compiler is complaining!
> Please note that the first language I learned was FORTRAN using
> fixed-form (punched card) format. There spaces are only meaningful
> inside string literals.
I don't know how to tell you this, but the rules for COBOL are not the rules
for ForTran, and the general expectation that the COBOL compiler will
accept ForTran source is not likely to be well-received by any COBOL
compiler!
> Is there a general rule about this for COBOL and has it changed with
> different versions of the standard?
The general stylistic rule for COBOL is that COBOL is based on English, in
which letters are combined into words that are separated by spaces and
punctuation marks. The punctuation rules are similar to those for English
as well, including the frequent requirement that certain punctuation marks
be followed by at least one space. Some specifics may have changed (the
relaxation of what may have been a rule that a left parenthesis of a pair
that encloses a subscript *must* be separated from the data name that's
being subscripted by a space), but a separator space where it is allowed is
rarely a Bad Idea in COBOL.
-Chuck Stevens
.
- Follow-Ups:
- Re: Where are spaces required in COBOL source code?
- From: Howard Brazee
- Re: Where are spaces required in COBOL source code?
- References:
- Prev by Date: Re: Occurs Depending Memory Use
- Next by Date: Re: Where are spaces required in COBOL source code?
- Previous by thread: Where are spaces required in COBOL source code?
- Next by thread: Re: Where are spaces required in COBOL source code?
- Index(es):
Relevant Pages
|