Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

/earth is 98% full ... please delete anyone you can.


devel / comp.lang.cobol / Order of CONSTANT definition/use in the 2002 standard???

SubjectAuthor
* Order of CONSTANT definition/use in the 2002 standard???Thomas David Rivers
+* Re: Order of CONSTANT definition/use in the 2002 standard???Bill Gunshannon
|`* Re: Order of CONSTANT definition/use in the 2002 standard???Thomas David Rivers
| `- Re: Order of CONSTANT definition/use in the 2002 standard???docdwarf
+- Re: Order of CONSTANT definition/use in the 2002 standard???Rick Smith
+* Re: Order of CONSTANT definition/use in the 2002 standard???Bill Gunshannon
|+* Re: Order of CONSTANT definition/use in the 2002 standard???Thomas David Rivers
||`* Re: Order of CONSTANT definition/use in the 2002 standard???Bill Gunshannon
|| `* Re: Order of CONSTANT definition/use in the 2002 standard???Thomas David Rivers
||  +* Re: Order of CONSTANT definition/use in the 2002 standard???Rick Smith
||  |`* Re: Order of CONSTANT definition/use in the 2002 standard???Thomas David Rivers
||  | `- Re: Order of CONSTANT definition/use in the 2002 standard???Rick Smith
||  `- Re: Order of CONSTANT definition/use in the 2002 standard???docdwarf
|`- Re: Order of CONSTANT definition/use in the 2002 standard???Arnold Trembley
+- Re: Order of CONSTANT definition/use in the 2002 standard???Vincent Coen
+- Re: Order of CONSTANT definition/use in the 2002 standard???Vincent Coen
`* Re: Order of CONSTANT definition/use in the 2002 standard???pete dashwood
 `* Re: Order of CONSTANT definition/use in the 2002 standard???Robert Jones
  +* Re: Order of CONSTANT definition/use in the 2002 standard???Robert Jones
  |`- Re: Order of CONSTANT definition/use in the 2002 standard???pete dashwood
  `- Re: Order of CONSTANT definition/use in the 2002 standard???pete dashwood

1
Order of CONSTANT definition/use in the 2002 standard???

<tb4j1c$20t$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=338&group=comp.lang.cobol#338

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!aioe.org!BFmHnFuKgZIQaiywaVRfTQ.user.46.165.242.75.POSTED!not-for-mail
From: rivers@dignus.com (Thomas David Rivers)
Newsgroups: comp.lang.cobol
Subject: Order of CONSTANT definition/use in the 2002 standard???
Date: Mon, 18 Jul 2022 01:41:01 -0400
Organization: Aioe.org NNTP Server
Message-ID: <tb4j1c$20t$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="2077"; posting-host="BFmHnFuKgZIQaiywaVRfTQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.13) Gecko/20061027
X-Accept-Language: en-us, en
X-Notice: Filtered by postfilter v. 0.9.2
 by: Thomas David Rivers - Mon, 18 Jul 2022 05:41 UTC

The COBOL 2002 standard adds constant-entry to the various
storage sections for defining compile-time constants.

However, I doesn't (at least in my scouring of the document) define
*when* these are extent and when they can be used.

For instance, this seems like a reasonable use:

IDENTIFICATION DIVISION.
PROGRAM-ID. ALPHEDIT.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A CONSTANT 5.
01 B CONSTANT 6.
01 CON CONSTANT A + B.
01 MYDATA PIC 9(CON).
PROCEDURE DIVISION.

Where the constant CON is used for the picture-string in the definition
of MYDATA.

But - I can't find where this would be an invalid COBOL program according
to the 2002 standard:

IDENTIFICATION DIVISION.
PROGRAM-ID. ALPHEDIT.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A CONSTANT 5.
01 CON CONSTANT A + B.
01 MYDATA PIC 9(CON).
01 B CONSTANT 6.
PROCEDURE DIVISION.

In this second example, the constant 'B' is used before it is defined.
But - the 2002 standard doesn't seem to make that illegal.

Is this a valid COBOL 2002 program? If not, can someone point me to
the phrase/definition in the 2002 standard that makes it invalid?

- Thanks! -
- Dave Rivers -

--
rivers@dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

Re: Order of CONSTANT definition/use in the 2002 standard???

<jjm4kaF7vq5U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=339&group=comp.lang.cobol#339

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gunshannon@gmail.com (Bill Gunshannon)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Mon, 18 Jul 2022 18:19:53 -0400
Lines: 59
Message-ID: <jjm4kaF7vq5U1@mid.individual.net>
References: <tb4j1c$20t$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net HGLW4ISZhCIOTUkqRM4a4wigVsd9TE6mdzzpMnp/hnxZjGRlbR
Cancel-Lock: sha1:YVBRNsyezDQE8QpYRo5irawcFZ4=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
In-Reply-To: <tb4j1c$20t$1@gioia.aioe.org>
 by: Bill Gunshannon - Mon, 18 Jul 2022 22:19 UTC

On 7/18/22 01:41, Thomas David Rivers wrote:
> The COBOL 2002 standard adds constant-entry to the various
> storage sections for defining compile-time constants.
>
> However, I doesn't (at least in my scouring of the document) define
> *when* these are extent and when they can be used.
>
> For instance, this seems like a reasonable use:
>
>       IDENTIFICATION DIVISION.
>        PROGRAM-ID. ALPHEDIT.
>       ENVIRONMENT DIVISION.
>       DATA DIVISION.
>        WORKING-STORAGE SECTION.
>       01  A CONSTANT 5.
>       01  B CONSTANT 6.
>       01  CON CONSTANT A + B.
>       01  MYDATA PIC 9(CON).
>       PROCEDURE DIVISION.
>
>
> Where the constant CON is used for the picture-string in the definition
> of MYDATA.
>
> But - I can't find where this would be an invalid COBOL program according
> to the 2002 standard:

What makes you think it should be? Compiles just fine with GnuCOBOL.

>
>       IDENTIFICATION DIVISION.
>        PROGRAM-ID. ALPHEDIT.
>       ENVIRONMENT DIVISION.
>       DATA DIVISION.
>        WORKING-STORAGE SECTION.
>       01  A CONSTANT 5.
>       01  CON CONSTANT A + B.
>       01  MYDATA PIC 9(CON).
>       01  B CONSTANT 6.
>       PROCEDURE DIVISION.
>
> In this second example, the constant 'B' is used before it is defined.
> But - the 2002 standard doesn't seem to make that illegal.

Using any data item before it is defined is an error and GnuCOBOL flags
it (in the obscure way it flags most undefined item errors. :-)

>
> Is this a valid COBOL 2002 program?  If not, can someone point me to
> the phrase/definition in the 2002 standard that makes it invalid?
>

Not having a copy of the 2002 standard I can't help with that
but then I wonder why it matters as long as the compilers are
getting it right. Do you have a compiler that doesn't?

bill

Re: Order of CONSTANT definition/use in the 2002 standard???

<62D50EF4.7060309@dignus.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=340&group=comp.lang.cobol#340

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!aioe.org!BFmHnFuKgZIQaiywaVRfTQ.user.46.165.242.75.POSTED!not-for-mail
From: rivers@dignus.com (Thomas David Rivers)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Mon, 18 Jul 2022 03:42:44 -0400
Organization: Aioe.org NNTP Server
Message-ID: <62D50EF4.7060309@dignus.com>
References: <tb4j1c$20t$1@gioia.aioe.org> <jjm4kaF7vq5U1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="13479"; posting-host="BFmHnFuKgZIQaiywaVRfTQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.13) Gecko/20061027
X-Accept-Language: en-us, en
X-Notice: Filtered by postfilter v. 0.9.2
 by: Thomas David Rivers - Mon, 18 Jul 2022 07:42 UTC

Bill Gunshannon wrote:

>
>>
>> IDENTIFICATION DIVISION.
>> PROGRAM-ID. ALPHEDIT.
>> ENVIRONMENT DIVISION.
>> DATA DIVISION.
>> WORKING-STORAGE SECTION.
>> 01 A CONSTANT 5.
>> 01 CON CONSTANT A + B.
>> 01 MYDATA PIC 9(CON).
>> 01 B CONSTANT 6.
>> PROCEDURE DIVISION.
>>
>> In this second example, the constant 'B' is used before it is defined.
>> But - the 2002 standard doesn't seem to make that illegal.
>
>
> Using any data item before it is defined is an error and GnuCOBOL flags
> it (in the obscure way it flags most undefined item errors. :-)
>
>>
>> Is this a valid COBOL 2002 program? If not, can someone point me to
>> the phrase/definition in the 2002 standard that makes it invalid?
>>
>
> Not having a copy of the 2002 standard I can't help with that
> but then I wonder why it matters as long as the compilers are
> getting it right. Do you have a compiler that doesn't?
>
> bill
>
>
Hi Bill!

*Many* thanks for taking a moment to reply.

You've hit on the crux of my question - it may intuitively be the rule that
you can't use a data-definition before it's defined; but that may be an
artifact
of how data-definitions appear before the PROCEDURE division and not
explicitly stated as such in the standard.

The absence of an explicit statement about definition-before-use (I've
perused
the IBM and Microfocus documentation on this, as well as the 2002 standard)
seems to be the problem here.

And - without such a prohibition, the second program (above) would be
valid,
and GnuCOBOL would be in error.

That's really what I'm asking...

Just what is the fundamental language requirement here - and where is that
articulated/documented.

If there is no mention of such a restriction, then the program should
compile...

And - I can think of more convoluted examples that would difficult for
a compiler
to untangle without that prohibition, so I'm hoping it exists
somewhere. The 2002
standard does restrict the values of the arithmetic-expression-1 to not
contain
a reference to the constant being defined, but the wording of that
would seem
to only be a direct reference - where, if we allowed forward references
to constants -
one could easily produce a recursive definition, e.g.

01 A CONSTANT B + C. --- doesn't seem to violate the
2002 standard restriction
01 B CONSTANT 5.
01 C CONSTANT A + 1. --- again, doesn't seem to violate
the 2002 standard restriction

An explicit statement regarding definition-before-use would clear this up.

So - it seems like that portion of the standard (and any other
documentation)
could use some clarification?

I can't think of a similar situation where a data-definition could be
defined
to use an identifier that wasn't already defined... so - perhaps this
question
has never been posed for clarification?

Or - much more likely - I'm missing something somewhere...

- Dave Rivers -

--
rivers@dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

Re: Order of CONSTANT definition/use in the 2002 standard???

<tb52pb$r9c$1@reader2.panix.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=341&group=comp.lang.cobol#341

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix1.panix.com!not-for-mail
From: docdwarf@panix.com
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Tue, 19 Jul 2022 01:52:44 -0000 (UTC)
Organization: Public Access Networks Corp.
Message-ID: <tb52pb$r9c$1@reader2.panix.com>
References: <tb4j1c$20t$1@gioia.aioe.org> <jjm4kaF7vq5U1@mid.individual.net> <62D50EF4.7060309@dignus.com>
Injection-Date: Tue, 19 Jul 2022 01:52:44 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="panix1.panix.com:166.84.1.1";
logging-data="27948"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
 by: docdwarf@panix.com - Tue, 19 Jul 2022 01:52 UTC

In article <62D50EF4.7060309@dignus.com>,
Thomas David Rivers <rivers@dignus.com> wrote:

[snip]

> The absence of an explicit statement about definition-before-use (I've
>perused
> the IBM and Microfocus documentation on this, as well as the 2002 standard)
> seems to be the problem here.
>
> And - without such a prohibition, the second program (above) would be
>valid,
> and GnuCOBOL would be in error.
>
> That's really what I'm asking...
>
> Just what is the fundamental language requirement here - and where is that
> articulated/documented.

[snip]

> Or - much more likely - I'm missing something somewhere...

It used to be coded:

IF PROGRAM-RUNS
NEXT SENTENCE
ELSE
PERFORM CODE-LIKE-THE-BLAZES
UNTIL FOOL-THING-WORKS.

This got upgraded to:

IF program-runs
CONTINUE
ELSE
PERFORM code-like-the-blazes
UNTIL fool-thing-works
END-IF

What you can think up is more an indication of what you can think up than
how either the Standard is written or any compiler implements the
standard.

(back in The Oldene Dayse I had a strip of greenbar with an error for a
SEARCH ALL reading EXPECTING WHEN - FOUND WHEN)

DD

Re: Order of CONSTANT definition/use in the 2002 standard???

<2afe619f-9c17-41b3-a7d3-01a44e8f3a85n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=342&group=comp.lang.cobol#342

  copy link   Newsgroups: comp.lang.cobol
X-Received: by 2002:a37:cc9:0:b0:6b5:ce98:334 with SMTP id 192-20020a370cc9000000b006b5ce980334mr13661479qkm.459.1658245951438;
Tue, 19 Jul 2022 08:52:31 -0700 (PDT)
X-Received: by 2002:a0d:eec3:0:b0:31c:3139:11fa with SMTP id
x186-20020a0deec3000000b0031c313911famr36786644ywe.51.1658245951206; Tue, 19
Jul 2022 08:52:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.cobol
Date: Tue, 19 Jul 2022 08:52:31 -0700 (PDT)
In-Reply-To: <tb4j1c$20t$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=98.180.88.86; posting-account=CcFQgQoAAAB4uPj9HOgZiRCM2Y_v-jmi
NNTP-Posting-Host: 98.180.88.86
References: <tb4j1c$20t$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2afe619f-9c17-41b3-a7d3-01a44e8f3a85n@googlegroups.com>
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
From: rs847925@gmail.com (Rick Smith)
Injection-Date: Tue, 19 Jul 2022 15:52:31 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2890
 by: Rick Smith - Tue, 19 Jul 2022 15:52 UTC

On Monday, July 18, 2022 at 5:24:00 PM UTC-4, Thomas David Rivers wrote:
> The COBOL 2002 standard adds constant-entry to the various
> storage sections for defining compile-time constants.
>
> However, I doesn't (at least in my scouring of the document) define
> *when* these are extent and when they can be used.
>
> For instance, this seems like a reasonable use:
>
> IDENTIFICATION DIVISION.
> PROGRAM-ID. ALPHEDIT.
> ENVIRONMENT DIVISION.
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 01 A CONSTANT 5.
> 01 B CONSTANT 6.
> 01 CON CONSTANT A + B.
> 01 MYDATA PIC 9(CON).
> PROCEDURE DIVISION.
>
>
> Where the constant CON is used for the picture-string in the definition
> of MYDATA.
>
> But - I can't find where this would be an invalid COBOL program according
> to the 2002 standard:
>
> IDENTIFICATION DIVISION.
> PROGRAM-ID. ALPHEDIT.
> ENVIRONMENT DIVISION.
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 01 A CONSTANT 5.
> 01 CON CONSTANT A + B.
> 01 MYDATA PIC 9(CON).
> 01 B CONSTANT 6.
> PROCEDURE DIVISION.
>
> In this second example, the constant 'B' is used before it is defined.
> But - the 2002 standard doesn't seem to make that illegal.
>
> Is this a valid COBOL 2002 program? If not, can someone point me to
> the phrase/definition in the 2002 standard that makes it invalid?

The standard says what MUST be done. It does not say HOW to do it.

During the compilation phase, the compiler may need to make multiple
passes to resolve incomplete references. These may occur with CONSTANT,
TYPEDEF, and SAME AS.

In particular, if the value of a CONSTANT or length of a TYPEDEF changes
during those multiple passes, the implementor is free to (and probably
should) give an error message.

Re: Order of CONSTANT definition/use in the 2002 standard???

<jjo7hsFj7rbU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=343&group=comp.lang.cobol#343

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gunshannon@gmail.com (Bill Gunshannon)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Tue, 19 Jul 2022 13:22:03 -0400
Lines: 53
Message-ID: <jjo7hsFj7rbU1@mid.individual.net>
References: <tb4j1c$20t$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net gGgkEajYpHYUdW4TgDhfeQykg+FryFOTMgTcricsVm1Mv+nmWG
Cancel-Lock: sha1:JRULUTHtvqeLMGq83ClDdCMU4Bo=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
In-Reply-To: <tb4j1c$20t$1@gioia.aioe.org>
 by: Bill Gunshannon - Tue, 19 Jul 2022 17:22 UTC

On 7/18/22 01:41, Thomas David Rivers wrote:
> The COBOL 2002 standard adds constant-entry to the various
> storage sections for defining compile-time constants.
>
> However, I doesn't (at least in my scouring of the document) define
> *when* these are extent and when they can be used.
>
> For instance, this seems like a reasonable use:
>
>       IDENTIFICATION DIVISION.
>        PROGRAM-ID. ALPHEDIT.
>       ENVIRONMENT DIVISION.
>       DATA DIVISION.
>        WORKING-STORAGE SECTION.
>       01  A CONSTANT 5.
>       01  B CONSTANT 6.
>       01  CON CONSTANT A + B.
>       01  MYDATA PIC 9(CON).
>       PROCEDURE DIVISION.
>
>
> Where the constant CON is used for the picture-string in the definition
> of MYDATA.
>
> But - I can't find where this would be an invalid COBOL program according
> to the 2002 standard:
>
>       IDENTIFICATION DIVISION.
>        PROGRAM-ID. ALPHEDIT.
>       ENVIRONMENT DIVISION.
>       DATA DIVISION.
>        WORKING-STORAGE SECTION.
>       01  A CONSTANT 5.
>       01  CON CONSTANT A + B.
>       01  MYDATA PIC 9(CON).
>       01  B CONSTANT 6.
>       PROCEDURE DIVISION.
>
> In this second example, the constant 'B' is used before it is defined.
> But - the 2002 standard doesn't seem to make that illegal.
>
> Is this a valid COBOL 2002 program?  If not, can someone point me to
> the phrase/definition in the 2002 standard that makes it invalid?

I am sure I could find where this is addressed given a chance to
read the actual standard. But I am certainly not going to pay
ISO more than $100 for the opportunity. I expect there is a place
where the standard addresses undefined data items. But it is
probably not where you are looking for it.

bill

Re: Order of CONSTANT definition/use in the 2002 standard???

<62D62878.5010908@dignus.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=344&group=comp.lang.cobol#344

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!aioe.org!BFmHnFuKgZIQaiywaVRfTQ.user.46.165.242.75.POSTED!not-for-mail
From: rivers@dignus.com (Thomas David Rivers)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Mon, 18 Jul 2022 23:43:52 -0400
Organization: Aioe.org NNTP Server
Message-ID: <62D62878.5010908@dignus.com>
References: <tb4j1c$20t$1@gioia.aioe.org> <jjo7hsFj7rbU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="51168"; posting-host="BFmHnFuKgZIQaiywaVRfTQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.13) Gecko/20061027
X-Accept-Language: en-us, en
X-Notice: Filtered by postfilter v. 0.9.2
 by: Thomas David Rivers - Tue, 19 Jul 2022 03:43 UTC

Bill Gunshannon wrote:

>
>> Is this a valid COBOL 2002 program? If not, can someone point me to
>> the phrase/definition in the 2002 standard that makes it invalid?
>
>
> I am sure I could find where this is addressed given a chance to
> read the actual standard. But I am certainly not going to pay
> ISO more than $100 for the opportunity. I expect there is a place
> where the standard addresses undefined data items. But it is
> probably not where you are looking for it.
>
> bill
>
>
Hi Bill!

Your idea about "undefined" was a terrific one - I did look through
the standard some more. There is even a section B.2 that explicitly
lists all the undefined behavior.

Unfortunately - there is no prohibition against a forward reference
to a constant. There doesn't seem to be a prohibition at all about a
forward
reference (although I'm hard-pressed to consider where that might happen?
Perhaps in a VALUE clause for a pointer data-definition?)

As far as I can tell, the standard allows forward references to
as-yet undefined
constants. So, a compiler would be required (as Rick mentioned) to make
multiple passes for resolving forward constant references.

I'm not sure what that would mean for constants that appear in different
sections? Can a constant in a WORKING STORAGE section reference a
constant in a LINKAGE section? What does that mean? What does it mean
if the constant is declared in the LINKAGE section of a sub-program with
the GLOBAL clause? Can it be referenced in the enclosing program? Can it
be referenced at a point in the enclosing program when the values of data
in the LINKAGE section of a sub-program are explicitly undefined? When
does
a compile-time constant become "undefined"?

The 2002 standard only seems to say:

5) Neither the value of literal-1 nor the value of any of the
literals in
arithmetic-expression-1 shall be dependent, directly or
indirectly,
upon the value of constant-name-1.

(constant-name-1 is the name being defined as a constant, with
arithmetic-expression-1
being the value.) And - since they mention "indirectly" - that would
seem to
imply the possibility of a forward reference to an as-yet-to-be-defined
constant (as I think
that would be about the only way to "indirectly" reference the constant
being defined...
wouldn't it?)

So - it would seem to explicitly disallow a recursive constant definition
(so the program snippet I posted is invalid) but - it appears to have
nothing to say
about the use of a constant before it's defined... and thus would allow it.

If that understanding is correct, the GnuCOBOL compiler needs to make an
adjustment for that. Microfocus implements level-78 "constants", I'm
not sure
what they do with any forward reference (if someone happens to have
that available
it might be nice to check what they do.)

But - I think some clarifications of what a "constant" is, and just
when it is
defined and available might be useful.

- Many thanks! -
- Dave Rivers -

--
rivers@dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

Re: Order of CONSTANT definition/use in the 2002 standard???

<jjol3gFlhqnU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=345&group=comp.lang.cobol#345

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: bill.gunshannon@gmail.com (Bill Gunshannon)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Tue, 19 Jul 2022 17:13:19 -0400
Lines: 119
Message-ID: <jjol3gFlhqnU1@mid.individual.net>
References: <tb4j1c$20t$1@gioia.aioe.org> <jjo7hsFj7rbU1@mid.individual.net>
<62D62878.5010908@dignus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net BBmRoRJVddYnDf3mAk9Naw5l0uLRTHe3vLdMrOYt4XOQzWyes+
Cancel-Lock: sha1:waxwUhroTiWp4YfYWIos8R0QhUc=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
In-Reply-To: <62D62878.5010908@dignus.com>
 by: Bill Gunshannon - Tue, 19 Jul 2022 21:13 UTC

On 7/18/22 23:43, Thomas David Rivers wrote:
> Bill Gunshannon wrote:
>
>>
>>> Is this a valid COBOL 2002 program?  If not, can someone point me to
>>> the phrase/definition in the 2002 standard that makes it invalid?
>>
>>
>> I am sure I could find where this is addressed given a chance to
>> read the actual standard.  But I am certainly not going to pay
>> ISO more than $100 for the opportunity.  I expect there is a place
>> where the standard addresses undefined data items.  But it is
>> probably not where you are looking for it.
>>
>> bill
>>
>>
> Hi Bill!
>
>  Your idea about "undefined" was a terrific one - I did look through
> the standard some more.  There is even a section B.2 that explicitly
> lists all the undefined behavior.

"Undefined behavior" is something totally different. You want to
look for "Undefined Data Item" or something similar.

>
>   Unfortunately - there is no prohibition against a forward reference
> to a constant.

Now you are calling it something else. If yo keep that up you'll
never find it. :-) What you are saying would make sense if, like
Pascal, COBOL had a FORWARD verb. :-) (No, FORWARD can not be used
for data items, even in Pascal.)

> There doesn't seem to be a prohibition at all about a
> forward
> reference (although I'm hard-pressed to consider where that might happen?
> Perhaps in a VALUE clause for a pointer data-definition?)

If use of an undefined data item is covered somewhere in the standard
then there would be no reason to address a forward reference as at the
time the reference is made it is an undefined data item. Unless there
was a FORWARD verb. :-)

>
>   As far as I can tell, the standard allows forward references to
> as-yet undefined
> constants.
Where does the standard allow that? Where does the standard even
mention forward references? My guess is it does not and you are
merely assuming if it doesn't explicitly prohibit it then it allows
it. Bad assumption. I am pretty sure that the standard does not
prohibit inline assembler, but I doubt that means it would be allowed.

> So, a compiler would be required (as Rick mentioned) to make
> multiple passes for resolving forward constant references.

No, the compiler is only required to do the things explicitly covered
in the standard. And, as I said, I would be willing to bet that there
is a specific reference somewhere in the standard to "undefined data
items".

>
>   I'm not sure what that would mean for constants that appear in different
> sections?   Can a constant in a WORKING STORAGE section reference a
> constant in a LINKAGE section?    What does that mean?   What does it mean
> if the constant is declared in the LINKAGE section of a sub-program with
> the GLOBAL clause?  Can it be referenced in the enclosing program?  Can it
> be referenced at a point in the enclosing program when the values of data
> in the LINKAGE section of a sub-program are explicitly undefined?  When
> does
> a compile-time constant become "undefined"?
>
>  The 2002 standard only seems to say:
>
>      5) Neither the value of literal-1 nor the value of any of the
> literals in
>          arithmetic-expression-1 shall be dependent, directly or
> indirectly,
>          upon the value of constant-name-1.
>
> (constant-name-1 is the name being defined as a constant, with
> arithmetic-expression-1
> being the value.)   And - since they mention "indirectly" - that would
> seem to
> imply the possibility of a forward reference to an as-yet-to-be-defined
> constant (as I think
> that would be about the only way to "indirectly" reference the constant
> being defined...
> wouldn't it?)
>
>  So - it would seem to explicitly disallow a recursive constant definition
> (so the program snippet I posted is invalid) but - it appears to have
> nothing to say
> about the use of a constant before it's defined... and thus would allow it.
>
>  If that understanding is correct, the GnuCOBOL compiler needs to make an
> adjustment for that.   Microfocus implements level-78 "constants", I'm
> not sure
> what they do with any forward reference (if someone happens to have that
> available
> it might be nice to check what they do.)
>  But - I think some clarifications of what a "constant" is, and just
> when it is
> defined and available might be useful.
>

I still think you are making a mountain out of a molehill. I do not
think that forward references are allowed. I have never seen any
mention of them in previous COBOL language references and I am unaware
of any mention of them in the 2002 standard. You are dealing with an
undefined data item at the time of its use and the result of that is
handled by the compiler as it always has been. Being a CONSTANT doesn't
impart any magical powers. It is still just a data item.

bill

Re: Order of CONSTANT definition/use in the 2002 standard???

<62D63F0B.9060009@dignus.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=346&group=comp.lang.cobol#346

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!aioe.org!BFmHnFuKgZIQaiywaVRfTQ.user.46.165.242.75.POSTED!not-for-mail
From: rivers@dignus.com (Thomas David Rivers)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Tue, 19 Jul 2022 01:20:11 -0400
Organization: Aioe.org NNTP Server
Message-ID: <62D63F0B.9060009@dignus.com>
References: <tb4j1c$20t$1@gioia.aioe.org> <jjo7hsFj7rbU1@mid.individual.net> <62D62878.5010908@dignus.com> <jjol3gFlhqnU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="63733"; posting-host="BFmHnFuKgZIQaiywaVRfTQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.13) Gecko/20061027
X-Notice: Filtered by postfilter v. 0.9.2
X-Accept-Language: en-us, en
 by: Thomas David Rivers - Tue, 19 Jul 2022 05:20 UTC

Bill Gunshannon wrote:

> On 7/18/22 23:43, Thomas David Rivers wrote:
>
>> Bill Gunshannon wrote:
>>
>>>
>>>> Is this a valid COBOL 2002 program? If not, can someone point me to
>>>> the phrase/definition in the 2002 standard that makes it invalid?
>>>
>>>
>>>
>>> I am sure I could find where this is addressed given a chance to
>>> read the actual standard. But I am certainly not going to pay
>>> ISO more than $100 for the opportunity. I expect there is a place
>>> where the standard addresses undefined data items. But it is
>>> probably not where you are looking for it.
>>>
>>> bill
>>>
>>>
>> Hi Bill!
>>
>> Your idea about "undefined" was a terrific one - I did look through
>> the standard some more. There is even a section B.2 that explicitly
>> lists all the undefined behavior.
>
>
> "Undefined behavior" is something totally different. You want to
> look for "Undefined Data Item" or something similar.

Hi Bill!!

I spent some time and looked at every occurence of "undefined" in the
standard,
there didn't seem (to me) to be any kind of statement like that.

>
>>
>> Unfortunately - there is no prohibition against a forward reference
>> to a constant.
>
>
> Now you are calling it something else. If yo keep that up you'll
> never find it. :-) What you are saying would make sense if, like
> Pascal, COBOL had a FORWARD verb. :-) (No, FORWARD can not be used
> for data items, even in Pascal.)

Yes - you are right - I did call it something else. It is really
important to
have precise terms.

Let's define a "forward reference" as a reference to a data definition that
is not yet defined at its use, but is subsequently defined (to distinguish
it from a name that is never defined.)
Going back to my very first post on this, this example contains a "forward
reference" to the constant-name 'B':

IDENTIFICATION DIVISION.
PROGRAM-ID. ALPHEDIT.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A CONSTANT 5.
01 CON CONSTANT A + B.
01 MYDATA PIC 9(CON).
01 B CONSTANT 6.
PROCEDURE DIVISION.

I can't find any reason in the standard why that shouldn't compile. I
also can't
find a statement about when the value of a constant is 'defined'.

The standard, under the "General Rules" for a CONSTANT (section 13.9.3)
says:

1) If literal-1 or compilation-variable-name-1 is specified, the
effect of specifying
constant-name-1 in other than this entry is as if literal-1 or
the text represented by
compilation-variable-name-1 were written where constant- name-1
is written.

...

3) If arithmetic-expression-1, data-name-1, or data-name-2 is
specified, the effect of
writing constant-name-1 in other than this entry is as if an
integer literal were
written where constant-name-1 is written. This integer literal
has the value specified in
these general rules.

It doesn't require that the definition be encountered before its use.

I _think_ this is the about the only situation where "something" can be
used
before it's defined. That is, the WORKING STORAGE section appears before
the PROCEDURE DIVISION, so any undefined (or unqualifiable) name is simply
undefined when encountered in the PROCEDURE DIVISION.

So, the reason I'm concerned about this, is I _think_ this is the first
time such
a situation could arise in COBOL? (I'd like to be found wrong on that
idea, if
someone cares to provide an example... )

>
>> There doesn't seem to be a prohibition at all about a
>> forward
>> reference (although I'm hard-pressed to consider where that might
>> happen?
>> Perhaps in a VALUE clause for a pointer data-definition?)
>
>
> If use of an undefined data item is covered somewhere in the standard
> then there would be no reason to address a forward reference as at the
> time the reference is made it is an undefined data item. Unless there
> was a FORWARD verb. :-)

Yes - that is a good point, I can't find anything in the standard that
talks about that in terms of the point-of-reference. The standard seems
to talk about compilation-data-name as being defined or not, but
nothing else.

I'm with you on the intuition that there must be something in the
standard
that speaks to this - but I can't find it.

>
>>
>> As far as I can tell, the standard allows forward references to
>> as-yet undefined
>> constants.
>
> Where does the standard allow that? Where does the standard even
> mention forward references? My guess is it does not and you are
> merely assuming if it doesn't explicitly prohibit it then it allows
> it. Bad assumption. I am pretty sure that the standard does not
> prohibit inline assembler, but I doubt that means it would be allowed.
>
>
>> So, a compiler would be required (as Rick mentioned) to make
>> multiple passes for resolving forward constant references.
>
>
> No, the compiler is only required to do the things explicitly covered
> in the standard. And, as I said, I would be willing to bet that there
> is a specific reference somewhere in the standard to "undefined data
> items".

>
>>
>> I'm not sure what that would mean for constants that appear in
>> different
>> sections? Can a constant in a WORKING STORAGE section reference a
>> constant in a LINKAGE section? What does that mean? What does it
>> mean
>> if the constant is declared in the LINKAGE section of a sub-program with
>> the GLOBAL clause? Can it be referenced in the enclosing program?
>> Can it
>> be referenced at a point in the enclosing program when the values of
>> data
>> in the LINKAGE section of a sub-program are explicitly undefined?
>> When does
>> a compile-time constant become "undefined"?
>>
>> The 2002 standard only seems to say:
>>
>> 5) Neither the value of literal-1 nor the value of any of the
>> literals in
>> arithmetic-expression-1 shall be dependent, directly or
>> indirectly,
>> upon the value of constant-name-1.
>>
>> (constant-name-1 is the name being defined as a constant, with
>> arithmetic-expression-1
>> being the value.) And - since they mention "indirectly" - that
>> would seem to
>> imply the possibility of a forward reference to an
>> as-yet-to-be-defined constant (as I think
>> that would be about the only way to "indirectly" reference the
>> constant being defined...
>> wouldn't it?)
>>
>> So - it would seem to explicitly disallow a recursive constant
>> definition
>> (so the program snippet I posted is invalid) but - it appears to have
>> nothing to say
>> about the use of a constant before it's defined... and thus would
>> allow it.
>>
>> If that understanding is correct, the GnuCOBOL compiler needs to
>> make an
>> adjustment for that. Microfocus implements level-78 "constants",
>> I'm not sure
>> what they do with any forward reference (if someone happens to have
>> that available
>> it might be nice to check what they do.)
>> But - I think some clarifications of what a "constant" is, and just
>> when it is
>> defined and available might be useful.
>>
>
> I still think you are making a mountain out of a molehill. I do not
> think that forward references are allowed. I have never seen any
> mention of them in previous COBOL language references and I am unaware
> of any mention of them in the 2002 standard. You are dealing with an
> undefined data item at the time of its use and the result of that is
> handled by the compiler as it always has been. Being a CONSTANT doesn't
> impart any magical powers. It is still just a data item.
>
> bill
>
Yeah - maybe I am... but with the strange phrase in the standard about
directly or indirectly referencing the name being defined, it seems to me
that the authors were actually _intending_ to allow a forward-reference
(as that would be the only way to arrive at an indirect reference - I
think.)
So, if the intent is to allow a forward reference, and there isn't anything
in the standard that disallows it, would it then be safe to say it's
allowed?


Click here to read the complete article
Re: Order of CONSTANT definition/use in the 2002 standard???

<4932deeb-810d-4773-92c2-66821053914bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=347&group=comp.lang.cobol#347

  copy link   Newsgroups: comp.lang.cobol
X-Received: by 2002:a05:620a:2619:b0:6b5:eddf:ef8e with SMTP id z25-20020a05620a261900b006b5eddfef8emr7654619qko.674.1658274192673;
Tue, 19 Jul 2022 16:43:12 -0700 (PDT)
X-Received: by 2002:a81:7dd6:0:b0:31c:85d9:8488 with SMTP id
y205-20020a817dd6000000b0031c85d98488mr38550097ywc.475.1658274192393; Tue, 19
Jul 2022 16:43:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.cobol
Date: Tue, 19 Jul 2022 16:43:12 -0700 (PDT)
In-Reply-To: <62D63F0B.9060009@dignus.com>
Injection-Info: google-groups.googlegroups.com; posting-host=98.180.88.86; posting-account=CcFQgQoAAAB4uPj9HOgZiRCM2Y_v-jmi
NNTP-Posting-Host: 98.180.88.86
References: <tb4j1c$20t$1@gioia.aioe.org> <jjo7hsFj7rbU1@mid.individual.net>
<62D62878.5010908@dignus.com> <jjol3gFlhqnU1@mid.individual.net> <62D63F0B.9060009@dignus.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4932deeb-810d-4773-92c2-66821053914bn@googlegroups.com>
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
From: rs847925@gmail.com (Rick Smith)
Injection-Date: Tue, 19 Jul 2022 23:43:12 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 13332
 by: Rick Smith - Tue, 19 Jul 2022 23:43 UTC

On Tuesday, July 19, 2022 at 5:53:17 PM UTC-4, Thomas David Rivers wrote:
> Bill Gunshannon wrote:
>
> > On 7/18/22 23:43, Thomas David Rivers wrote:
> >
> >> Bill Gunshannon wrote:
> >>
> >>>
> >>>> Is this a valid COBOL 2002 program? If not, can someone point me to
> >>>> the phrase/definition in the 2002 standard that makes it invalid?
> >>>
> >>>
> >>>
> >>> I am sure I could find where this is addressed given a chance to
> >>> read the actual standard. But I am certainly not going to pay
> >>> ISO more than $100 for the opportunity. I expect there is a place
> >>> where the standard addresses undefined data items. But it is
> >>> probably not where you are looking for it.
> >>>
> >>> bill
> >>>
> >>>
> >> Hi Bill!
> >>
> >> Your idea about "undefined" was a terrific one - I did look through
> >> the standard some more. There is even a section B.2 that explicitly
> >> lists all the undefined behavior.
> >
> >
> > "Undefined behavior" is something totally different. You want to
> > look for "Undefined Data Item" or something similar.
> Hi Bill!!
>
> I spent some time and looked at every occurence of "undefined" in the
> standard,
> there didn't seem (to me) to be any kind of statement like that.
> >
> >>
> >> Unfortunately - there is no prohibition against a forward reference
> >> to a constant.
> >
> >
> > Now you are calling it something else. If yo keep that up you'll
> > never find it. :-) What you are saying would make sense if, like
> > Pascal, COBOL had a FORWARD verb. :-) (No, FORWARD can not be used
> > for data items, even in Pascal.)
> Yes - you are right - I did call it something else. It is really
> important to
> have precise terms.
>
> Let's define a "forward reference" as a reference to a data definition that
> is not yet defined at its use, but is subsequently defined (to distinguish
> it from a name that is never defined.)
>
> Going back to my very first post on this, this example contains a "forward
> reference" to the constant-name 'B':
> IDENTIFICATION DIVISION.
> PROGRAM-ID. ALPHEDIT.
> ENVIRONMENT DIVISION.
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 01 A CONSTANT 5.
> 01 CON CONSTANT A + B.
> 01 MYDATA PIC 9(CON).
> 01 B CONSTANT 6.
> PROCEDURE DIVISION.
> I can't find any reason in the standard why that shouldn't compile. I
> also can't
> find a statement about when the value of a constant is 'defined'.
>
> The standard, under the "General Rules" for a CONSTANT (section 13.9.3)
> says:
>
> 1) If literal-1 or compilation-variable-name-1 is specified, the
> effect of specifying
> constant-name-1 in other than this entry is as if literal-1 or
> the text represented by
> compilation-variable-name-1 were written where constant- name-1
> is written.
>
> ...
>
> 3) If arithmetic-expression-1, data-name-1, or data-name-2 is
> specified, the effect of
> writing constant-name-1 in other than this entry is as if an
> integer literal were
> written where constant-name-1 is written. This integer literal
> has the value specified in
> these general rules.
>
> It doesn't require that the definition be encountered before its use.
>
> I _think_ this is the about the only situation where "something" can be
> used
> before it's defined. That is, the WORKING STORAGE section appears before
> the PROCEDURE DIVISION, so any undefined (or unqualifiable) name is simply
> undefined when encountered in the PROCEDURE DIVISION.
>
> So, the reason I'm concerned about this, is I _think_ this is the first
> time such
> a situation could arise in COBOL? (I'd like to be found wrong on that
> idea, if
> someone cares to provide an example... )

Forward references have been part of COBOL since, like, forever.

For the ENVIRONMENT DIVISION, forward references occur for
FILE STATUS and RECORD KEY names. In the DATA DIVISION
FILE SECTION file-description-entry, the record-clause may refer
to a data-item in the WORKING-STORAGE SECTION for the length
of a record read or to be written. In the PROCEDURE DIVISION,
forward references to procedure-names are normal.

What is different with 2002, is the need to resolve all references
in the WORKING-STORAGE SECTION by potentially making multiple
passes before processing the PROCEDURE DIVISION.

> >> There doesn't seem to be a prohibition at all about a
> >> forward
> >> reference (although I'm hard-pressed to consider where that might
> >> happen?
> >> Perhaps in a VALUE clause for a pointer data-definition?)
> >
> >
> > If use of an undefined data item is covered somewhere in the standard
> > then there would be no reason to address a forward reference as at the
> > time the reference is made it is an undefined data item. Unless there
> > was a FORWARD verb. :-)
> Yes - that is a good point, I can't find anything in the standard that
> talks about that in terms of the point-of-reference. The standard seems
> to talk about compilation-data-name as being defined or not, but
> nothing else.
>
> I'm with you on the intuition that there must be something in the
> standard
> that speaks to this - but I can't find it.
> >
> >>
> >> As far as I can tell, the standard allows forward references to
> >> as-yet undefined
> >> constants.
> >
> > Where does the standard allow that? Where does the standard even
> > mention forward references? My guess is it does not and you are
> > merely assuming if it doesn't explicitly prohibit it then it allows
> > it. Bad assumption. I am pretty sure that the standard does not
> > prohibit inline assembler, but I doubt that means it would be allowed.

The standard doesn't mention forward references because they are
part of COBOL, or indeed any programming language.

> >> So, a compiler would be required (as Rick mentioned) to make
> >> multiple passes for resolving forward constant references.
> >
> >
> > No, the compiler is only required to do the things explicitly covered
> > in the standard. And, as I said, I would be willing to bet that there
> > is a specific reference somewhere in the standard to "undefined data
> > items".
>
> >
> >>
> >> I'm not sure what that would mean for constants that appear in
> >> different
> >> sections? Can a constant in a WORKING STORAGE section reference a
> >> constant in a LINKAGE section? What does that mean? What does it
> >> mean
> >> if the constant is declared in the LINKAGE section of a sub-program with
> >> the GLOBAL clause? Can it be referenced in the enclosing program?
> >> Can it
> >> be referenced at a point in the enclosing program when the values of
> >> data
> >> in the LINKAGE section of a sub-program are explicitly undefined?
> >> When does
> >> a compile-time constant become "undefined"?
> >>
> >> The 2002 standard only seems to say:
> >>
> >> 5) Neither the value of literal-1 nor the value of any of the
> >> literals in
> >> arithmetic-expression-1 shall be dependent, directly or
> >> indirectly,
> >> upon the value of constant-name-1.
> >>
> >> (constant-name-1 is the name being defined as a constant, with
> >> arithmetic-expression-1
> >> being the value.) And - since they mention "indirectly" - that
> >> would seem to
> >> imply the possibility of a forward reference to an
> >> as-yet-to-be-defined constant (as I think
> >> that would be about the only way to "indirectly" reference the
> >> constant being defined...
> >> wouldn't it?)
> >>
> >> So - it would seem to explicitly disallow a recursive constant
> >> definition
> >> (so the program snippet I posted is invalid) but - it appears to have
> >> nothing to say
> >> about the use of a constant before it's defined... and thus would
> >> allow it.
> >>
> >> If that understanding is correct, the GnuCOBOL compiler needs to
> >> make an
> >> adjustment for that. Microfocus implements level-78 "constants",
> >> I'm not sure
> >> what they do with any forward reference (if someone happens to have
> >> that available
> >> it might be nice to check what they do.)
> >> But - I think some clarifications of what a "constant" is, and just
> >> when it is
> >> defined and available might be useful.
> >>
> >
> > I still think you are making a mountain out of a molehill. I do not
> > think that forward references are allowed. I have never seen any
> > mention of them in previous COBOL language references and I am unaware
> > of any mention of them in the 2002 standard. You are dealing with an
> > undefined data item at the time of its use and the result of that is
> > handled by the compiler as it always has been. Being a CONSTANT doesn't
> > impart any magical powers. It is still just a data item.
> >
> > bill
> >
> Yeah - maybe I am... but with the strange phrase in the standard about
> directly or indirectly referencing the name being defined, it seems to me
> that the authors were actually _intending_ to allow a forward-reference
> (as that would be the only way to arrive at an indirect reference - I
> think.)
> So, if the intent is to allow a forward reference, and there isn't anything
> in the standard that disallows it, would it then be safe to say it's
> allowed?
>
> Also - there are some questions I still have about constants defined in
> a sub-program's WORKING STORAGE or LINKAGE sections with the GLOBAL
> clause attached. Are such constants visible in the containing program?
> The standard is clared that such data is "undefined" when the sub-program
> is not active (which makes absolute sense) but does not prohibit the
> reference
> to them. Only that if you do, you are entering the "realm of undefined" if
> the sub-program is not active (also, this begs a question about _which_ one
> you are referencing if the sub-program is at all RECURSIVE - but that's a
> different question.) So - what does this mean about CONSTANTs defined
> in such sections? Are they globally visible at compile-time - or only
> intended
> to be visible when the sub-program is active? I can't imagine that's
> the intent,
> but that seems to be what one can consider from the verbiage in the
> standard.


Click here to read the complete article
Re: Order of CONSTANT definition/use in the 2002 standard???

<mdmdnWdqS47HyUr_nZ2dnUU7-c2dnZ2d@giganews.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=348&group=comp.lang.cobol#348

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 19 Jul 2022 20:03:22 -0500
Date: Tue, 19 Jul 2022 20:03:22 -0500
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Reply-To: arnold.trembley@att.net
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Content-Language: en-US
Newsgroups: comp.lang.cobol
References: <tb4j1c$20t$1@gioia.aioe.org> <jjo7hsFj7rbU1@mid.individual.net>
From: arnold.trembley@att.net (Arnold Trembley)
In-Reply-To: <jjo7hsFj7rbU1@mid.individual.net>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Antivirus: Avast (VPS 220719-12, 7/19/2022), Outbound message
X-Antivirus-Status: Clean
Message-ID: <mdmdnWdqS47HyUr_nZ2dnUU7-c2dnZ2d@giganews.com>
Lines: 24
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-U5zKt2o6H5OsGekSr4sKpVKc5wzxlh+bSlNzJWZYBqmq1tV7qcud0ahyYgBPTYjn016E9lp7Iff11iC!gwxTrS2YwuZaGK2mnVq2JpYeY0py/K3a5AudKQ/Sbtgamsf5JWXFeeml/ehrW3bMZ9tqz9aVKw==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2127
 by: Arnold Trembley - Wed, 20 Jul 2022 01:03 UTC

On 7/19/2022 12:22 PM, Bill Gunshannon wrote:
> On 7/18/22 01:41, Thomas David Rivers wrote:
>> (SNIP)
>
> I am sure I could find where this is addressed given a chance to
> read the actual standard.  But I am certainly not going to pay
> ISO more than $100 for the opportunity.  I expect there is a place
> where the standard addresses undefined data items.  But it is
> probably not where you are looking for it.
>
> bill
>
>

I think this link to a copy of the 2014 standard still works, and it is
still free. It's an 8 megabyte PDF.

http://www.open-std.org/jtc1/sc22/open/ISO-IECJTC1-SC22_N4561_ISO_IEC_FCD_1989__Information_technol.pdf

Watch out for the URL wrapping around...

--
https://www.arnoldtrembley.com/

Re: Order of CONSTANT definition/use in the 2002 standard???

<62D70BA7.7020809@dignus.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=349&group=comp.lang.cobol#349

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!aioe.org!BFmHnFuKgZIQaiywaVRfTQ.user.46.165.242.75.POSTED!not-for-mail
From: rivers@dignus.com (Thomas David Rivers)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Tue, 19 Jul 2022 15:53:11 -0400
Organization: Aioe.org NNTP Server
Message-ID: <62D70BA7.7020809@dignus.com>
References: <tb4j1c$20t$1@gioia.aioe.org> <jjo7hsFj7rbU1@mid.individual.net> <62D62878.5010908@dignus.com> <jjol3gFlhqnU1@mid.individual.net> <62D63F0B.9060009@dignus.com> <4932deeb-810d-4773-92c2-66821053914bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="37352"; posting-host="BFmHnFuKgZIQaiywaVRfTQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.13) Gecko/20061027
X-Notice: Filtered by postfilter v. 0.9.2
X-Accept-Language: en-us, en
 by: Thomas David Rivers - Tue, 19 Jul 2022 19:53 UTC

Rick Smith wrote:

>Forward references have been part of COBOL since, like, forever.
>
>For the ENVIRONMENT DIVISION, forward references occur for
>FILE STATUS and RECORD KEY names. In the DATA DIVISION
>FILE SECTION file-description-entry, the record-clause may refer
>to a data-item in the WORKING-STORAGE SECTION for the length
>of a record read or to be written. In the PROCEDURE DIVISION,
>forward references to procedure-names are normal.
>
>

Many thanks Rick for pointing these out!

>What is different with 2002, is the need to resolve all references
>in the WORKING-STORAGE SECTION by potentially making multiple
>passes before processing the PROCEDURE DIVISION.
>
>

Yes - that's what I was kinda getting at, albeit very indirectly;
but if you can allow a forward reference then multiple passes would
be needed.

So, then, we can assert that the example I posted with the forward
reference _should_ compile by a 2002/2014 conforming compiler?

>
>
>>
>
>The standard doesn't mention forward references because they are
>part of COBOL, or indeed any programming language.
>
>

They aren't part of many programming languages - which is where I
was coming from. Many languages require a declaration/definition
before a use.

>
>
>>
>
>A CONSTANT, defined anywhere in the DATA DIVISION, may be referenced
>anywhere a value may be used in the DATA DIVISION (and as I recall, possibly
>in the ENVIRONMENT DIVISION). It may be referenced in the PROCEDURE
>DIVISION.
>
>If the CONSTANT has the GLOBAL attribute, it may be referenced in any
>contained program; however, it may not be referenced in any containing
>program.
>
>

Yes - I was wondering why the constants aren't part of a new section,
instead
of sprinkled-in with the other data-definitions from the existing
section. It
was somewhat confusing, to me, that constants "live" in WORKING STORAGE,
LOCAL STORE or LINKAGE. Is this simply an artifact of being a
data-definition
and those various sections cause no distinction in a CONSTANT
data-definition?
(I _think_ that's what you are saying above?)

>
>
>
>The 2002 standard was not broadly implemented. Most are using the
>current 2014 standard. The next revision, currently 202X, may be approved
>this year.
>
>

Oh my! I didn't even realize - I've since made a trip to the ANSI store
for the 2014 standard... thanks for pointing that out!

>
>
>>p.s. Does anyone know a way to contact the COBOL standard committee to
>>ask about this stuff? Is there a newsgroup or other facility
>>where the
>>committee members might "hang out"? Perhaps I need to be redirected
>>to such a forum...
>>
>>
>
>AFAIK the committee members communicate using a restricted access
>site. Any questions about the standard would have to be sent "snail mail"
>to the committee through INCITS (for the US) or ISO (international). I don't
>have specific information and haven't cared to look for it.
>
>

*Many* thanks for your response! It was very helpful!

- Dave Rivers -

--
rivers@dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

Re: Order of CONSTANT definition/use in the 2002 standard???

<1658324191@f1.n250.z2.fidonet.ftn>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=350&group=comp.lang.cobol#350

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: VBCoen@gmail.com (Vincent Coen)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Wed, 20 Jul 2022 14:36:31 +0100
Organization: A noiseless patient Spider
Lines: 94
Sender: "Vincent Coen" <VBCoen@gmail.com>
Message-ID: <1658324191@f1.n250.z2.fidonet.ftn>
References: <tb4j1c$20t$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="cc13be9a4b746b633fb38813469ac591";
logging-data="1759783"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XiU3s69lp/AELVbJMAEn7"
Cancel-Lock: sha1:7VgdZi0jmZ61ckcyQXiJC3G2Bas=
X-FTN-Sender: Vincent Coen <Vincent.Coen@f1.n250.z2.fidonet.org>
X-FTN-PID: GED+LNX 1.1.5-b20180707
X-Newsreader: GoldED+/LNX 1.1.5 (Linux 5.15.50-server-1.mga8 CPU UNKNOWN)
X-FTN-SEEN-BY: 25/0 250/0 1 2 4 5 6 12 263/0 371/52
X-FTN-PATH: 250/1
X-FTN-CHRS: UTF-8 2
X-FTN-AREA: COMP.LANG.COBOL
REPLY: gioia.aioe.org 4f5e648e
X-Origin-Newsgroups: comp.lang.cobol
X-FTN-TZUTC: 0100
X-FTN-TID: MBSE-FIDO 1.0.8 (Linux-x86_64)
X-FTN-MSGID: 2:250/1@fidonet 62d80779
X-Comment-To: "Thomas David Rivers" <rivers@dignus.com>
 by: Vincent Coen - Wed, 20 Jul 2022 13:36 UTC

Hello Thomas!

Monday July 18 2022 06:41, Thomas David Rivers wrote to All:

Second example does not work for GC v3.2 so cobc code is not searching
forwards when parsing sources in this instance HOWEVER that said I would
suggest it is a bug.

Since the 60's (By my 75 year old memory) I have not noticed that the
requirement for the need for backward references to a vars is required.

For other programming languages going back to the same time frame it has
been and no I cannot remember what one's.

It does depend on the way parsing works for a specific compiler or
assembler.

You example of code will be used to create a bug / ticket for the GC v3.2
compiler so will see what the GC programmers have to say on it.

As personally it should work.

Small point here though, where forward references of vars are used such as
file status vars are used and defined later (for obvious reasons) this is
picked up as normal BUT they do not use any form of computation etc.

In your example it does so it might be that the initial parsing is
rejecting it before it can get to any later stage of pre-processing.

That said why would you not define before usage any way, if nothing else it
keeps program logic flow easier to read.

See also examples of CDF usage.

Vince

> The COBOL 2002 standard adds constant-entry to the various
> storage sections for defining compile-time constants.

> However, I doesn't (at least in my scouring of the document) define
> *when* these are extent and when they can be used.

> For instance, this seems like a reasonable use:

> IDENTIFICATION DIVISION.
> PROGRAM-ID. ALPHEDIT.
> ENVIRONMENT DIVISION.
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 01 A CONSTANT 5.
> 01 B CONSTANT 6.
> 01 CON CONSTANT A + B.
> 01 MYDATA PIC 9(CON).
> PROCEDURE DIVISION.

> Where the constant CON is used for the picture-string in the
> definition of MYDATA.

> But - I can't find where this would be an invalid COBOL program
> according to the 2002 standard:

> IDENTIFICATION DIVISION.
> PROGRAM-ID. ALPHEDIT.
> ENVIRONMENT DIVISION.
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 01 A CONSTANT 5.
> 01 CON CONSTANT A + B.
> 01 MYDATA PIC 9(CON).
> 01 B CONSTANT 6.
> PROCEDURE DIVISION.

> In this second example, the constant 'B' is used before it is defined.
> But - the 2002 standard doesn't seem to make that illegal.

> Is this a valid COBOL 2002 program? If not, can someone point me to
> the phrase/definition in the 2002 standard that makes it invalid?

> - Thanks! -
> - Dave Rivers -

> --
> rivers@dignus.com Work: (919) 676-0847
> Get your mainframe programming tools at http://www.dignus.com

Vincent

Re: Order of CONSTANT definition/use in the 2002 standard???

<1658325924@f1.n250.z2.fidonet.ftn>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=351&group=comp.lang.cobol#351

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: VBCoen@gmail.com (Vincent Coen)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Wed, 20 Jul 2022 15:05:24 +0100
Organization: A noiseless patient Spider
Lines: 13
Sender: "Vincent Coen" <VBCoen@gmail.com>
Message-ID: <1658325924@f1.n250.z2.fidonet.ftn>
References: <tb4j1c$20t$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="cc13be9a4b746b633fb38813469ac591";
logging-data="1759783"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iuK+g/C9s9GVftpvTQCxl"
Cancel-Lock: sha1:iA1HtfVuTWgjNi3vbK6gmCRPzLA=
X-FTN-Sender: Vincent Coen <Vincent.Coen@f1.n250.z2.fidonet.org>
X-FTN-PID: GED+LNX 1.1.5-b20180707
X-Newsreader: GoldED+/LNX 1.1.5 (Linux 5.15.50-server-1.mga8 CPU UNKNOWN)
X-FTN-CHRS: UTF-8 2
X-FTN-SEEN-BY: 25/0 250/0 1 2 4 5 6 12 263/0 371/52
X-FTN-PATH: 250/1
REPLY: 2:250/1@fidonet 62d80779
X-FTN-AREA: COMP.LANG.COBOL
X-FTN-TID: MBSE-FIDO 1.0.8 (Linux-x86_64)
X-Origin-Newsgroups: comp.lang.cobol
X-FTN-TZUTC: 0100
X-Comment-To: "Thomas David Rivers" <>
X-FTN-MSGID: 2:250/1@fidonet 62d80c34
 by: Vincent Coen - Wed, 20 Jul 2022 14:05 UTC

Hello Thomas!

Wednesday July 20 2022 14:36, I wrote to Thomas David Rivers:

Follow on - [bugs:#846] Forward var reference using arithmetic fails

So will see what is said about this and you can follow up if registered on
Sourceforge at https://sourceforge.net/p/gnucobol/bugs/846/

Vincent

Re: Order of CONSTANT definition/use in the 2002 standard???

<f5bbf8cc-9318-4596-87e8-688030be020an@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=352&group=comp.lang.cobol#352

  copy link   Newsgroups: comp.lang.cobol
X-Received: by 2002:a05:620a:22f4:b0:6b5:dda2:8426 with SMTP id p20-20020a05620a22f400b006b5dda28426mr14307411qki.659.1658337995625;
Wed, 20 Jul 2022 10:26:35 -0700 (PDT)
X-Received: by 2002:a5b:3c9:0:b0:66f:8b9a:fd7b with SMTP id
t9-20020a5b03c9000000b0066f8b9afd7bmr35959185ybp.51.1658337995311; Wed, 20
Jul 2022 10:26:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.cobol
Date: Wed, 20 Jul 2022 10:26:35 -0700 (PDT)
In-Reply-To: <62D70BA7.7020809@dignus.com>
Injection-Info: google-groups.googlegroups.com; posting-host=98.180.88.86; posting-account=CcFQgQoAAAB4uPj9HOgZiRCM2Y_v-jmi
NNTP-Posting-Host: 98.180.88.86
References: <tb4j1c$20t$1@gioia.aioe.org> <jjo7hsFj7rbU1@mid.individual.net>
<62D62878.5010908@dignus.com> <jjol3gFlhqnU1@mid.individual.net>
<62D63F0B.9060009@dignus.com> <4932deeb-810d-4773-92c2-66821053914bn@googlegroups.com>
<62D70BA7.7020809@dignus.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f5bbf8cc-9318-4596-87e8-688030be020an@googlegroups.com>
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
From: rs847925@gmail.com (Rick Smith)
Injection-Date: Wed, 20 Jul 2022 17:26:35 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 79
 by: Rick Smith - Wed, 20 Jul 2022 17:26 UTC

On Wednesday, July 20, 2022 at 8:57:14 AM UTC-4, Thomas David Rivers wrote:
> Rick Smith wrote:
>
> >Forward references have been part of COBOL since, like, forever.
> >
> >For the ENVIRONMENT DIVISION, forward references occur for
> >FILE STATUS and RECORD KEY names. In the DATA DIVISION
> >FILE SECTION file-description-entry, the record-clause may refer
> >to a data-item in the WORKING-STORAGE SECTION for the length
> >of a record read or to be written. In the PROCEDURE DIVISION,
> >forward references to procedure-names are normal.
> >
> >
> Many thanks Rick for pointing these out!
> >What is different with 2002, is the need to resolve all references
> >in the WORKING-STORAGE SECTION by potentially making multiple
> >passes before processing the PROCEDURE DIVISION.
> >
> >
> Yes - that's what I was kinda getting at, albeit very indirectly;
> but if you can allow a forward reference then multiple passes would
> be needed.
>
> So, then, we can assert that the example I posted with the forward
> reference _should_ compile by a 2002/2014 conforming compiler?

I don't know to which example you refer, but I think Vincent is probably
addressing that issue.

> >The standard doesn't mention forward references because they are
> >part of COBOL, or indeed any programming language.
> >
> >
> They aren't part of many programming languages - which is where I
> was coming from. Many languages require a declaration/definition
> before a use.

Forward references for data definitions, yes, many; but not labels (except
Pascal as I recall). In particular, any two-pass assembler may use forward
references to data definitions as well as labels.

The point, with regard to the COBOL standard, is that the standard requires
that some items, DIVISIONs, SECTIONs, parts of the formats of various
elements, etc., to appear in a certain order. Where the standard is silent on
order, it is the obligation of the compiler developer to make it work for the
purpose of claiming conformance to the standard.

> >A CONSTANT, defined anywhere in the DATA DIVISION, may be referenced
> >anywhere a value may be used in the DATA DIVISION (and as I recall, possibly
> >in the ENVIRONMENT DIVISION). It may be referenced in the PROCEDURE
> >DIVISION.
> >
> >If the CONSTANT has the GLOBAL attribute, it may be referenced in any
> >contained program; however, it may not be referenced in any containing
> >program.
> >
> >
> Yes - I was wondering why the constants aren't part of a new section,
> instead
> of sprinkled-in with the other data-definitions from the existing
> section. It
> was somewhat confusing, to me, that constants "live" in WORKING STORAGE,
> LOCAL STORE or LINKAGE. Is this simply an artifact of being a
> data-definition
> and those various sections cause no distinction in a CONSTANT
> data-definition?
> (I _think_ that's what you are saying above?)

There was a CONSTANT SECTION in the COBOL language definition prior
to the 1968 standard.

> >The 2002 standard was not broadly implemented. Most are using the
> >current 2014 standard. The next revision, currently 202X, may be approved
> >this year.
> >
> >
> Oh my! I didn't even realize - I've since made a trip to the ANSI store
> for the 2014 standard... thanks for pointing that out!

[snip]

Re: Order of CONSTANT definition/use in the 2002 standard???

<tba20m$dfi$1@reader2.panix.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=353&group=comp.lang.cobol#353

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix1.panix.com!not-for-mail
From: docdwarf@panix.com
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Wed, 20 Jul 2022 23:10:14 -0000 (UTC)
Organization: Public Access Networks Corp.
Message-ID: <tba20m$dfi$1@reader2.panix.com>
References: <tb4j1c$20t$1@gioia.aioe.org> <62D62878.5010908@dignus.com> <jjol3gFlhqnU1@mid.individual.net> <62D63F0B.9060009@dignus.com>
Injection-Date: Wed, 20 Jul 2022 23:10:14 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="panix1.panix.com:166.84.1.1";
logging-data="13810"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
 by: docdwarf@panix.com - Wed, 20 Jul 2022 23:10 UTC

In article <62D63F0B.9060009@dignus.com>,
Thomas David Rivers <rivers@dignus.com> wrote:
>Bill Gunshannon wrote:
>
>> On 7/18/22 23:43, Thomas David Rivers wrote:
>>
>>> Bill Gunshannon wrote:
>>>
>>>>
>>>>> Is this a valid COBOL 2002 program? If not, can someone point me to
>>>>> the phrase/definition in the 2002 standard that makes it invalid?
>>>>
>>>>
>>>>
>>>> I am sure I could find where this is addressed given a chance to
>>>> read the actual standard. But I am certainly not going to pay
>>>> ISO more than $100 for the opportunity. I expect there is a place
>>>> where the standard addresses undefined data items. But it is
>>>> probably not where you are looking for it.
>>>>
>>>> bill
>>>>
>>>>
>>> Hi Bill!
>>>
>>> Your idea about "undefined" was a terrific one - I did look through
>>> the standard some more. There is even a section B.2 that explicitly
>>> lists all the undefined behavior.
>>
>>
>> "Undefined behavior" is something totally different. You want to
>> look for "Undefined Data Item" or something similar.
>
>
>Hi Bill!!
>
> I spent some time and looked at every occurence of "undefined" in the
>standard,
> there didn't seem (to me) to be any kind of statement like that.
>
>>
>>>
>>> Unfortunately - there is no prohibition against a forward reference
>>> to a constant.
>>
>>
>> Now you are calling it something else. If yo keep that up you'll
>> never find it. :-) What you are saying would make sense if, like
>> Pascal, COBOL had a FORWARD verb. :-) (No, FORWARD can not be used
>> for data items, even in Pascal.)
>
>
> Yes - you are right - I did call it something else. It is really
>important to
> have precise terms.
>
> Let's define a "forward reference" as a reference to a data definition that
> is not yet defined at its use, but is subsequently defined (to distinguish
> it from a name that is never defined.)
>
> Going back to my very first post on this, this example contains a "forward
> reference" to the constant-name 'B':
>
> IDENTIFICATION DIVISION.
> PROGRAM-ID. ALPHEDIT.
> ENVIRONMENT DIVISION.
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 01 A CONSTANT 5.
> 01 CON CONSTANT A + B.
> 01 MYDATA PIC 9(CON).
> 01 B CONSTANT 6.
> PROCEDURE DIVISION.
>
> I can't find any reason in the standard why that shouldn't compile. I
>also can't
> find a statement about when the value of a constant is 'defined'.
>
> The standard, under the "General Rules" for a CONSTANT (section 13.9.3)
>says:
>
> 1) If literal-1 or compilation-variable-name-1 is specified, the
>effect of specifying
> constant-name-1 in other than this entry is as if literal-1 or
>the text represented by
> compilation-variable-name-1 were written where constant- name-1
>is written.
>
> ...
>
> 3) If arithmetic-expression-1, data-name-1, or data-name-2 is
>specified, the effect of
> writing constant-name-1 in other than this entry is as if an
>integer literal were
> written where constant-name-1 is written. This integer literal
>has the value specified in
> these general rules.
>
> It doesn't require that the definition be encountered before its use.
>
> I _think_ this is the about the only situation where "something" can be
>used
> before it's defined. That is, the WORKING STORAGE section appears before
> the PROCEDURE DIVISION, so any undefined (or unqualifiable) name is simply
> undefined when encountered in the PROCEDURE DIVISION.
>
> So, the reason I'm concerned about this, is I _think_ this is the first
>time such
> a situation could arise in COBOL? (I'd like to be found wrong on that
>idea, if
> someone cares to provide an example... )
>
>
>
>>
>>> There doesn't seem to be a prohibition at all about a
>>> forward
>>> reference (although I'm hard-pressed to consider where that might
>>> happen?
>>> Perhaps in a VALUE clause for a pointer data-definition?)
>>
>>
>> If use of an undefined data item is covered somewhere in the standard
>> then there would be no reason to address a forward reference as at the
>> time the reference is made it is an undefined data item. Unless there
>> was a FORWARD verb. :-)
>
>
> Yes - that is a good point, I can't find anything in the standard that
> talks about that in terms of the point-of-reference. The standard seems
> to talk about compilation-data-name as being defined or not, but
>nothing else.
>
> I'm with you on the intuition that there must be something in the
>standard
> that speaks to this - but I can't find it.
>
>>
>>>
>>> As far as I can tell, the standard allows forward references to
>>> as-yet undefined
>>> constants.
>>
>> Where does the standard allow that? Where does the standard even
>> mention forward references? My guess is it does not and you are
>> merely assuming if it doesn't explicitly prohibit it then it allows
>> it. Bad assumption. I am pretty sure that the standard does not
>> prohibit inline assembler, but I doubt that means it would be allowed.
>>
>>
>>> So, a compiler would be required (as Rick mentioned) to make
>>> multiple passes for resolving forward constant references.
>>
>>
>> No, the compiler is only required to do the things explicitly covered
>> in the standard. And, as I said, I would be willing to bet that there
>> is a specific reference somewhere in the standard to "undefined data
>> items".
>
>>
>>>
>>> I'm not sure what that would mean for constants that appear in
>>> different
>>> sections? Can a constant in a WORKING STORAGE section reference a
>>> constant in a LINKAGE section? What does that mean? What does it
>>> mean
>>> if the constant is declared in the LINKAGE section of a sub-program with
>>> the GLOBAL clause? Can it be referenced in the enclosing program?
>>> Can it
>>> be referenced at a point in the enclosing program when the values of
>>> data
>>> in the LINKAGE section of a sub-program are explicitly undefined?
>>> When does
>>> a compile-time constant become "undefined"?
>>>
>>> The 2002 standard only seems to say:
>>>
>>> 5) Neither the value of literal-1 nor the value of any of the
>>> literals in
>>> arithmetic-expression-1 shall be dependent, directly or
>>> indirectly,
>>> upon the value of constant-name-1.
>>>
>>> (constant-name-1 is the name being defined as a constant, with
>>> arithmetic-expression-1
>>> being the value.) And - since they mention "indirectly" - that
>>> would seem to
>>> imply the possibility of a forward reference to an
>>> as-yet-to-be-defined constant (as I think
>>> that would be about the only way to "indirectly" reference the
>>> constant being defined...
>>> wouldn't it?)
>>>
>>> So - it would seem to explicitly disallow a recursive constant
>>> definition
>>> (so the program snippet I posted is invalid) but - it appears to have
>>> nothing to say
>>> about the use of a constant before it's defined... and thus would
>>> allow it.
>>>
>>> If that understanding is correct, the GnuCOBOL compiler needs to
>>> make an
>>> adjustment for that. Microfocus implements level-78 "constants",
>>> I'm not sure
>>> what they do with any forward reference (if someone happens to have
>>> that available
>>> it might be nice to check what they do.)
>>> But - I think some clarifications of what a "constant" is, and just
>>> when it is
>>> defined and available might be useful.
>>>
>>
>> I still think you are making a mountain out of a molehill. I do not
>> think that forward references are allowed. I have never seen any
>> mention of them in previous COBOL language references and I am unaware
>> of any mention of them in the 2002 standard. You are dealing with an
>> undefined data item at the time of its use and the result of that is
>> handled by the compiler as it always has been. Being a CONSTANT doesn't
>> impart any magical powers. It is still just a data item.
>>
>> bill
>>
> Yeah - maybe I am... but with the strange phrase in the standard about
> directly or indirectly referencing the name being defined, it seems to me
> that the authors were actually _intending_ to allow a forward-reference
> (as that would be the only way to arrive at an indirect reference - I
>think.)
> So, if the intent is to allow a forward reference, and there isn't anything
> in the standard that disallows it, would it then be safe to say it's
>allowed?
>
> Also - there are some questions I still have about constants defined in
> a sub-program's WORKING STORAGE or LINKAGE sections with the GLOBAL
> clause attached. Are such constants visible in the containing program?
> The standard is clared that such data is "undefined" when the sub-program
> is not active (which makes absolute sense) but does not prohibit the
>reference
> to them. Only that if you do, you are entering the "realm of undefined" if
> the sub-program is not active (also, this begs a question about _which_ one
> you are referencing if the sub-program is at all RECURSIVE - but that's a
> different question.) So - what does this mean about CONSTANTs defined
> in such sections? Are they globally visible at compile-time - or only
>intended
> to be visible when the sub-program is active? I can't imagine that's
>the intent,
> but that seems to be what one can consider from the verbiage in the
>standard.
>
> If the standard is really just a "set of guidelines" - then, I guess
>I'll just have
> to be disappointed.
>
> I was hoping someone from the committee might be lurking here with
> some rationale, or perhaps could tell me where my interpretation is wrong
> and why it is wrong... clearly, like you say, I'm confused somewhere....
>
> Of course - it may all be moot - how many COBOL 2002 compliant
>implementations
> are there? If no-one bothers to implement the features the way the
>standard
> indicates, then what's the point? I may be absolutely making the problem
> bigger than reality suggests.
>
> - Dave Rivers -
>
>p.s. Does anyone know a way to contact the COBOL standard committee to
> ask about this stuff? Is there a newsgroup or other facility
>where the
> committee members might "hang out"? Perhaps I need to be redirected
> to such a forum...
>
>--
>rivers@dignus.com Work: (919) 676-0847
>Get your mainframe programming tools at http://www.dignus.com


Click here to read the complete article
Re: Order of CONSTANT definition/use in the 2002 standard???

<jkcth9Ftas7U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=357&group=comp.lang.cobol#357

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: dashwood@enternet.co.nz (pete dashwood)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Thu, 28 Jul 2022 01:39:56 +1200
Lines: 80
Message-ID: <jkcth9Ftas7U1@mid.individual.net>
References: <tb4j1c$20t$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 9XNvcidv8x/+Kcm7h2Y4cgF37PfSk5sGlmB56VYzCbTrsN1cMt
Cancel-Lock: sha1:JsDnB2UTTvR7DrWyLhmC/kPgg4U=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Content-Language: en-US
In-Reply-To: <tb4j1c$20t$1@gioia.aioe.org>
 by: pete dashwood - Wed, 27 Jul 2022 13:39 UTC

On 18/07/2022 17:41, Thomas David Rivers wrote:
> The COBOL 2002 standard adds constant-entry to the various
> storage sections for defining compile-time constants.
>
> However, I doesn't (at least in my scouring of the document) define
> *when* these are extent and when they can be used.
>
> For instance, this seems like a reasonable use:
>
>       IDENTIFICATION DIVISION.
>        PROGRAM-ID. ALPHEDIT.
>       ENVIRONMENT DIVISION.
>       DATA DIVISION.
>        WORKING-STORAGE SECTION.
>       01  A CONSTANT 5.
>       01  B CONSTANT 6.
>       01  CON CONSTANT A + B.
>       01  MYDATA PIC 9(CON).
>       PROCEDURE DIVISION.
>
>
> Where the constant CON is used for the picture-string in the definition
> of MYDATA.
>
> But - I can't find where this would be an invalid COBOL program according
> to the 2002 standard:
>
>       IDENTIFICATION DIVISION.
>        PROGRAM-ID. ALPHEDIT.
>       ENVIRONMENT DIVISION.
>       DATA DIVISION.
>        WORKING-STORAGE SECTION.
>       01  A CONSTANT 5.
>       01  CON CONSTANT A + B.
>       01  MYDATA PIC 9(CON).
>       01  B CONSTANT 6.
>       PROCEDURE DIVISION.
>
> In this second example, the constant 'B' is used before it is defined.
> But - the 2002 standard doesn't seem to make that illegal.
>
> Is this a valid COBOL 2002 program?  If not, can someone point me to
> the phrase/definition in the 2002 standard that makes it invalid?
>
>    - Thanks! -
>   - Dave Rivers -
>
>
Please excuse the simple question of an old man:

Don't constants in COBOL need to be defined in the DATA DIVISION after
WORKING-STORAGE as...
DATA DIVISION.
.... WORKING-STORAGE SECTION.
....
CONSTANT SECTION.
....
PROCEDURE DIVISION.
etc...?

I'm not familiar with the 2002 standard in COBOL and I don't have a copy
of it, but in the flavours of COBOL I have seen where CONSTANTS are
supported, they do require to be defined in the CONSTANT SECTION.

Having so defined them, they then acquire a "read only" quality and
cannot be set to anything other than the initial value. (Compiler
diagnostic if you try...)

Of course, with the never-ending efforts to make COBOL more like
NOT-COBOL, this constraint may well have been abolished.

Might be worth checking what the 2002 standard says about the CONSTANT
SECTION (if anything...)

Cheers,

Pete.

--
I used to write *COBOL*; now I can do *anything*...

Re: Order of CONSTANT definition/use in the 2002 standard???

<909e4043-05a1-4efd-bd40-3fb6af2b2888n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=360&group=comp.lang.cobol#360

  copy link   Newsgroups: comp.lang.cobol
X-Received: by 2002:a05:620a:2909:b0:6b6:a94:a988 with SMTP id m9-20020a05620a290900b006b60a94a988mr21233944qkp.350.1659017973740;
Thu, 28 Jul 2022 07:19:33 -0700 (PDT)
X-Received: by 2002:a25:9002:0:b0:66e:9d65:80f3 with SMTP id
s2-20020a259002000000b0066e9d6580f3mr20576762ybl.595.1659017973495; Thu, 28
Jul 2022 07:19:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.cobol
Date: Thu, 28 Jul 2022 07:19:33 -0700 (PDT)
In-Reply-To: <jkcth9Ftas7U1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=35.176.220.132; posting-account=YfOAvQoAAAB-xX6lFkGnJ-ulWzvPONPD
NNTP-Posting-Host: 35.176.220.132
References: <tb4j1c$20t$1@gioia.aioe.org> <jkcth9Ftas7U1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <909e4043-05a1-4efd-bd40-3fb6af2b2888n@googlegroups.com>
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
From: 0robert.jones@gmail.com (Robert Jones)
Injection-Date: Thu, 28 Jul 2022 14:19:33 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4019
 by: Robert Jones - Thu, 28 Jul 2022 14:19 UTC

On Wednesday, July 27, 2022 at 2:39:56 PM UTC+1, dash...@enternet.co.nz wrote:
> On 18/07/2022 17:41, Thomas David Rivers wrote:
> > The COBOL 2002 standard adds constant-entry to the various
> > storage sections for defining compile-time constants.
> >
> > However, I doesn't (at least in my scouring of the document) define
> > *when* these are extent and when they can be used.
> >
> > For instance, this seems like a reasonable use:
> >
> > IDENTIFICATION DIVISION.
> > PROGRAM-ID. ALPHEDIT.
> > ENVIRONMENT DIVISION.
> > DATA DIVISION.
> > WORKING-STORAGE SECTION.
> > 01 A CONSTANT 5.
> > 01 B CONSTANT 6.
> > 01 CON CONSTANT A + B.
> > 01 MYDATA PIC 9(CON).
> > PROCEDURE DIVISION.
> >
> >
> > Where the constant CON is used for the picture-string in the definition
> > of MYDATA.
> >
> > But - I can't find where this would be an invalid COBOL program according
> > to the 2002 standard:
> >
> > IDENTIFICATION DIVISION.
> > PROGRAM-ID. ALPHEDIT.
> > ENVIRONMENT DIVISION.
> > DATA DIVISION.
> > WORKING-STORAGE SECTION.
> > 01 A CONSTANT 5.
> > 01 CON CONSTANT A + B.
> > 01 MYDATA PIC 9(CON).
> > 01 B CONSTANT 6.
> > PROCEDURE DIVISION.
> >
> > In this second example, the constant 'B' is used before it is defined.
> > But - the 2002 standard doesn't seem to make that illegal.
> >
> > Is this a valid COBOL 2002 program? If not, can someone point me to
> > the phrase/definition in the 2002 standard that makes it invalid?
> >
> > - Thanks! -
> > - Dave Rivers -
> >
> >
> Please excuse the simple question of an old man:
>
> Don't constants in COBOL need to be defined in the DATA DIVISION after
> WORKING-STORAGE as...
> DATA DIVISION.
> ... WORKING-STORAGE SECTION.
> ...
> CONSTANT SECTION.
> ...
> PROCEDURE DIVISION.
> etc...?
>
> I'm not familiar with the 2002 standard in COBOL and I don't have a copy
> of it, but in the flavours of COBOL I have seen where CONSTANTS are
> supported, they do require to be defined in the CONSTANT SECTION.
>
> Having so defined them, they then acquire a "read only" quality and
> cannot be set to anything other than the initial value. (Compiler
> diagnostic if you try...)
>
> Of course, with the never-ending efforts to make COBOL more like
> NOT-COBOL, this constraint may well have been abolished.
>
> Might be worth checking what the 2002 standard says about the CONSTANT
> SECTION (if anything...)
>
> Cheers,
>
> Pete.
>
> --
> I used to write *COBOL*; now I can do *anything*...
The CONSTANT RECORD clause may be specified at the 01 level anywhere in the Working-Storage and Linkage sections in the 2014 standard.

Re: Order of CONSTANT definition/use in the 2002 standard???

<636c9702-6d0b-4215-8bb5-89f54b222f26n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=365&group=comp.lang.cobol#365

  copy link   Newsgroups: comp.lang.cobol
X-Received: by 2002:a05:620a:28cf:b0:6b5:e32f:febb with SMTP id l15-20020a05620a28cf00b006b5e32ffebbmr7218659qkp.258.1659220916723;
Sat, 30 Jul 2022 15:41:56 -0700 (PDT)
X-Received: by 2002:a05:690c:82b:b0:322:6481:e969 with SMTP id
by11-20020a05690c082b00b003226481e969mr8387530ywb.375.1659220916477; Sat, 30
Jul 2022 15:41:56 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.cobol
Date: Sat, 30 Jul 2022 15:41:56 -0700 (PDT)
In-Reply-To: <909e4043-05a1-4efd-bd40-3fb6af2b2888n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=35.176.220.132; posting-account=YfOAvQoAAAB-xX6lFkGnJ-ulWzvPONPD
NNTP-Posting-Host: 35.176.220.132
References: <tb4j1c$20t$1@gioia.aioe.org> <jkcth9Ftas7U1@mid.individual.net> <909e4043-05a1-4efd-bd40-3fb6af2b2888n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <636c9702-6d0b-4215-8bb5-89f54b222f26n@googlegroups.com>
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
From: 0robert.jones@gmail.com (Robert Jones)
Injection-Date: Sat, 30 Jul 2022 22:41:56 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4426
 by: Robert Jones - Sat, 30 Jul 2022 22:41 UTC

On Thursday, July 28, 2022 at 3:19:35 PM UTC+1, Robert Jones wrote:
> On Wednesday, July 27, 2022 at 2:39:56 PM UTC+1, dash...@enternet.co.nz wrote:
> > On 18/07/2022 17:41, Thomas David Rivers wrote:
> > > The COBOL 2002 standard adds constant-entry to the various
> > > storage sections for defining compile-time constants.
> > >
> > > However, I doesn't (at least in my scouring of the document) define
> > > *when* these are extent and when they can be used.
> > >
> > > For instance, this seems like a reasonable use:
> > >
> > > IDENTIFICATION DIVISION.
> > > PROGRAM-ID. ALPHEDIT.
> > > ENVIRONMENT DIVISION.
> > > DATA DIVISION.
> > > WORKING-STORAGE SECTION.
> > > 01 A CONSTANT 5.
> > > 01 B CONSTANT 6.
> > > 01 CON CONSTANT A + B.
> > > 01 MYDATA PIC 9(CON).
> > > PROCEDURE DIVISION.
> > >
> > >
> > > Where the constant CON is used for the picture-string in the definition
> > > of MYDATA.
> > >
> > > But - I can't find where this would be an invalid COBOL program according
> > > to the 2002 standard:
> > >
> > > IDENTIFICATION DIVISION.
> > > PROGRAM-ID. ALPHEDIT.
> > > ENVIRONMENT DIVISION.
> > > DATA DIVISION.
> > > WORKING-STORAGE SECTION.
> > > 01 A CONSTANT 5.
> > > 01 CON CONSTANT A + B.
> > > 01 MYDATA PIC 9(CON).
> > > 01 B CONSTANT 6.
> > > PROCEDURE DIVISION.
> > >
> > > In this second example, the constant 'B' is used before it is defined.
> > > But - the 2002 standard doesn't seem to make that illegal.
> > >
> > > Is this a valid COBOL 2002 program? If not, can someone point me to
> > > the phrase/definition in the 2002 standard that makes it invalid?
> > >
> > > - Thanks! -
> > > - Dave Rivers -
> > >
> > >
> > Please excuse the simple question of an old man:
> >
> > Don't constants in COBOL need to be defined in the DATA DIVISION after
> > WORKING-STORAGE as...
> > DATA DIVISION.
> > ... WORKING-STORAGE SECTION.
> > ...
> > CONSTANT SECTION.
> > ...
> > PROCEDURE DIVISION.
> > etc...?
> >
> > I'm not familiar with the 2002 standard in COBOL and I don't have a copy
> > of it, but in the flavours of COBOL I have seen where CONSTANTS are
> > supported, they do require to be defined in the CONSTANT SECTION.
> >
> > Having so defined them, they then acquire a "read only" quality and
> > cannot be set to anything other than the initial value. (Compiler
> > diagnostic if you try...)
> >
> > Of course, with the never-ending efforts to make COBOL more like
> > NOT-COBOL, this constraint may well have been abolished.
> >
> > Might be worth checking what the 2002 standard says about the CONSTANT
> > SECTION (if anything...)
> >
> > Cheers,
> >
> > Pete.
> >
> > --
> > I used to write *COBOL*; now I can do *anything*...
> The CONSTANT RECORD clause may be specified at the 01 level anywhere in the Working-Storage and Linkage sections in the 2014 standard.
I should have added that there is also a constant entry that consists of a single elementary item with the keyword CONSTANT, which is what I now think was the subject of the question. It may be anywhere in the data division.

Re: Order of CONSTANT definition/use in the 2002 standard???

<jmdigqFen2rU2@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=385&group=comp.lang.cobol#385

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: dashwood@enternet.co.nz (pete dashwood)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Sun, 21 Aug 2022 14:10:36 +1200
Lines: 90
Message-ID: <jmdigqFen2rU2@mid.individual.net>
References: <tb4j1c$20t$1@gioia.aioe.org> <jkcth9Ftas7U1@mid.individual.net>
<909e4043-05a1-4efd-bd40-3fb6af2b2888n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net YZgJ2DyLaI6pH2fDdIq2yQFrhnGrhFEtsb3iMOtfGTe1DDPz/S
Cancel-Lock: sha1:4UJjusbcS8ui8i+kdZQwH5phhUc=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Content-Language: en-US
In-Reply-To: <909e4043-05a1-4efd-bd40-3fb6af2b2888n@googlegroups.com>
 by: pete dashwood - Sun, 21 Aug 2022 02:10 UTC

On 29/07/2022 02:19, Robert Jones wrote:
> On Wednesday, July 27, 2022 at 2:39:56 PM UTC+1, dash...@enternet.co.nz wrote:
>> On 18/07/2022 17:41, Thomas David Rivers wrote:
>>> The COBOL 2002 standard adds constant-entry to the various
>>> storage sections for defining compile-time constants.
>>>
>>> However, I doesn't (at least in my scouring of the document) define
>>> *when* these are extent and when they can be used.
>>>
>>> For instance, this seems like a reasonable use:
>>>
>>> IDENTIFICATION DIVISION.
>>> PROGRAM-ID. ALPHEDIT.
>>> ENVIRONMENT DIVISION.
>>> DATA DIVISION.
>>> WORKING-STORAGE SECTION.
>>> 01 A CONSTANT 5.
>>> 01 B CONSTANT 6.
>>> 01 CON CONSTANT A + B.
>>> 01 MYDATA PIC 9(CON).
>>> PROCEDURE DIVISION.
>>>
>>>
>>> Where the constant CON is used for the picture-string in the definition
>>> of MYDATA.
>>>
>>> But - I can't find where this would be an invalid COBOL program according
>>> to the 2002 standard:
>>>
>>> IDENTIFICATION DIVISION.
>>> PROGRAM-ID. ALPHEDIT.
>>> ENVIRONMENT DIVISION.
>>> DATA DIVISION.
>>> WORKING-STORAGE SECTION.
>>> 01 A CONSTANT 5.
>>> 01 CON CONSTANT A + B.
>>> 01 MYDATA PIC 9(CON).
>>> 01 B CONSTANT 6.
>>> PROCEDURE DIVISION.
>>>
>>> In this second example, the constant 'B' is used before it is defined.
>>> But - the 2002 standard doesn't seem to make that illegal.
>>>
>>> Is this a valid COBOL 2002 program? If not, can someone point me to
>>> the phrase/definition in the 2002 standard that makes it invalid?
>>>
>>> - Thanks! -
>>> - Dave Rivers -
>>>
>>>
>> Please excuse the simple question of an old man:
>>
>> Don't constants in COBOL need to be defined in the DATA DIVISION after
>> WORKING-STORAGE as...
>> DATA DIVISION.
>> ... WORKING-STORAGE SECTION.
>> ...
>> CONSTANT SECTION.
>> ...
>> PROCEDURE DIVISION.
>> etc...?
>>
>> I'm not familiar with the 2002 standard in COBOL and I don't have a copy
>> of it, but in the flavours of COBOL I have seen where CONSTANTS are
>> supported, they do require to be defined in the CONSTANT SECTION.
>>
>> Having so defined them, they then acquire a "read only" quality and
>> cannot be set to anything other than the initial value. (Compiler
>> diagnostic if you try...)
>>
>> Of course, with the never-ending efforts to make COBOL more like
>> NOT-COBOL, this constraint may well have been abolished.
>>
>> Might be worth checking what the 2002 standard says about the CONSTANT
>> SECTION (if anything...)
>>
>> Cheers,
>>
>> Pete.
>>
>> --
>> I used to write *COBOL*; now I can do *anything*...
> The CONSTANT RECORD clause may be specified at the 01 level anywhere in the Working-Storage and Linkage sections in the 2014 standard.

OK, Thanks for that, Robert.

Pete.

--
I used to write *COBOL*; now I can do *anything*...

Re: Order of CONSTANT definition/use in the 2002 standard???

<jmdiijFen2rU3@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=386&group=comp.lang.cobol#386

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: dashwood@enternet.co.nz (pete dashwood)
Newsgroups: comp.lang.cobol
Subject: Re: Order of CONSTANT definition/use in the 2002 standard???
Date: Sun, 21 Aug 2022 14:11:32 +1200
Lines: 93
Message-ID: <jmdiijFen2rU3@mid.individual.net>
References: <tb4j1c$20t$1@gioia.aioe.org> <jkcth9Ftas7U1@mid.individual.net>
<909e4043-05a1-4efd-bd40-3fb6af2b2888n@googlegroups.com>
<636c9702-6d0b-4215-8bb5-89f54b222f26n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net CdfDYmja3lK+lOxnpt193QQrMXyEyug9dmNvARHmtT2igCoGj1
Cancel-Lock: sha1:rRAnx9VAYhDD+LeFninC/mULZEE=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Content-Language: en-US
In-Reply-To: <636c9702-6d0b-4215-8bb5-89f54b222f26n@googlegroups.com>
 by: pete dashwood - Sun, 21 Aug 2022 02:11 UTC

On 31/07/2022 10:41, Robert Jones wrote:
> On Thursday, July 28, 2022 at 3:19:35 PM UTC+1, Robert Jones wrote:
>> On Wednesday, July 27, 2022 at 2:39:56 PM UTC+1, dash...@enternet.co.nz wrote:
>>> On 18/07/2022 17:41, Thomas David Rivers wrote:
>>>> The COBOL 2002 standard adds constant-entry to the various
>>>> storage sections for defining compile-time constants.
>>>>
>>>> However, I doesn't (at least in my scouring of the document) define
>>>> *when* these are extent and when they can be used.
>>>>
>>>> For instance, this seems like a reasonable use:
>>>>
>>>> IDENTIFICATION DIVISION.
>>>> PROGRAM-ID. ALPHEDIT.
>>>> ENVIRONMENT DIVISION.
>>>> DATA DIVISION.
>>>> WORKING-STORAGE SECTION.
>>>> 01 A CONSTANT 5.
>>>> 01 B CONSTANT 6.
>>>> 01 CON CONSTANT A + B.
>>>> 01 MYDATA PIC 9(CON).
>>>> PROCEDURE DIVISION.
>>>>
>>>>
>>>> Where the constant CON is used for the picture-string in the definition
>>>> of MYDATA.
>>>>
>>>> But - I can't find where this would be an invalid COBOL program according
>>>> to the 2002 standard:
>>>>
>>>> IDENTIFICATION DIVISION.
>>>> PROGRAM-ID. ALPHEDIT.
>>>> ENVIRONMENT DIVISION.
>>>> DATA DIVISION.
>>>> WORKING-STORAGE SECTION.
>>>> 01 A CONSTANT 5.
>>>> 01 CON CONSTANT A + B.
>>>> 01 MYDATA PIC 9(CON).
>>>> 01 B CONSTANT 6.
>>>> PROCEDURE DIVISION.
>>>>
>>>> In this second example, the constant 'B' is used before it is defined.
>>>> But - the 2002 standard doesn't seem to make that illegal.
>>>>
>>>> Is this a valid COBOL 2002 program? If not, can someone point me to
>>>> the phrase/definition in the 2002 standard that makes it invalid?
>>>>
>>>> - Thanks! -
>>>> - Dave Rivers -
>>>>
>>>>
>>> Please excuse the simple question of an old man:
>>>
>>> Don't constants in COBOL need to be defined in the DATA DIVISION after
>>> WORKING-STORAGE as...
>>> DATA DIVISION.
>>> ... WORKING-STORAGE SECTION.
>>> ...
>>> CONSTANT SECTION.
>>> ...
>>> PROCEDURE DIVISION.
>>> etc...?
>>>
>>> I'm not familiar with the 2002 standard in COBOL and I don't have a copy
>>> of it, but in the flavours of COBOL I have seen where CONSTANTS are
>>> supported, they do require to be defined in the CONSTANT SECTION.
>>>
>>> Having so defined them, they then acquire a "read only" quality and
>>> cannot be set to anything other than the initial value. (Compiler
>>> diagnostic if you try...)
>>>
>>> Of course, with the never-ending efforts to make COBOL more like
>>> NOT-COBOL, this constraint may well have been abolished.
>>>
>>> Might be worth checking what the 2002 standard says about the CONSTANT
>>> SECTION (if anything...)
>>>
>>> Cheers,
>>>
>>> Pete.
>>>
>>> --
>>> I used to write *COBOL*; now I can do *anything*...
>> The CONSTANT RECORD clause may be specified at the 01 level anywhere in the Working-Storage and Linkage sections in the 2014 standard.
> I should have added that there is also a constant entry that consists of a single elementary item with the keyword CONSTANT, which is what I now think was the subject of the question. It may be anywhere in the data division.

OK, thanks.

Pete.

--
I used to write *COBOL*; now I can do *anything*...

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor