So, I am n a discussion with someone regarding the use of "-" and "_"
in COBOL names. It started using VMS COBOL but moved to others. The following was run under GnuCOBOL.
------------------------------------
C:\Work>type m2.cob
IDENTIFICATION DIVISION.
PROGRAM-ID.M2.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I-V PIC 9(9) DISPLAY EXTERNAL.
PROCEDURE DIVISION.
MAIN-PARAGRAPH.
MOVE 123 TO I-V
CALL "R2"
STOP RUN.
C:\Work>type r2.cob
IDENTIFICATION DIVISION.
PROGRAM-ID.R2.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I_V PIC 9(9) DISPLAY EXTERNAL.
PROCEDURE DIVISION.
MAIN-PARAGRAPH.
DISPLAY I_V.
END PROGRAM R2.
C:\Work>cobc -Wall -free -x m2.cob r2.cob
C:\Work>m2
000000123
----------------------------------------
Are "I-V" and "I_V" the same object? If so, where is this documented?
So, I am n a discussion with someone regarding the use of "-" and "_"C:\Work>> type m2.cob
in COBOL names. It started using VMS COBOL but moved to others. The following was run under GnuCOBOL.
------------------------------------
IDENTIFICATION DIVISION.
PROGRAM-ID.M2.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I-V PIC 9(9) DISPLAY EXTERNAL.
PROCEDURE DIVISION.
MAIN-PARAGRAPH.
MOVE 123 TO I-V
CALL "R2"
STOP RUN.
IDENTIFICATION DIVISION.
PROGRAM-ID.R2.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I_V PIC 9(9) DISPLAY EXTERNAL.
PROCEDURE DIVISION.
MAIN-PARAGRAPH.
DISPLAY I_V.
END PROGRAM R2.
000000123
----------------------------------------
Are "I-V" and "I_V" the same object? If so, where is this documented?
On 9/9/2023 7:42 PM, bill wrote:
So, I am n a discussion with someone regarding the use of "-" and "_"
in COBOL names. It started using VMS COBOL but moved to others. The
following was run under GnuCOBOL.
------------------------------------
C:\Work>type m2.cob
IDENTIFICATION DIVISION.
PROGRAM-ID.M2.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I-V PIC 9(9) DISPLAY EXTERNAL.
PROCEDURE DIVISION.
MAIN-PARAGRAPH.
MOVE 123 TO I-V
CALL "R2"
STOP RUN.
C:\Work>type r2.cob
IDENTIFICATION DIVISION.
PROGRAM-ID.R2.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I_V PIC 9(9) DISPLAY EXTERNAL.
PROCEDURE DIVISION.
MAIN-PARAGRAPH.
DISPLAY I_V.
END PROGRAM R2.
C:\Work>cobc -Wall -free -x m2.cob r2.cob
C:\Work>m2
000000123
----------------------------------------
Are "I-V" and "I_V" the same object? If so, where is this documented?
You could have asked in c.o.v..
:-)
https://sourceforge.net/projects/gnucobol/
<quote>
GnuCOBOL (formerly OpenCOBOL) is a free, modern COBOL compiler. GnuCOBOL implements a substantial part of the COBOL 85, X/Open COBOL and newer
ISO COBOL standards (2002, 2014, 2023), as well as many extensions
included in other COBOL compilers (IBM COBOL, MicroFocus COBOL,
ACUCOBOL-GT and others).
</quote>
The important part is "X/Open COBOL".
https://pubs.opengroup.org/onlinepubs/009680799/toc.pdf
<quote>
8.10 EXTERNAL NAMES AND CASE CONVENTIONS
...
• working storage items having the EXTERNAL clause (lower-case letters, digits and
hyphens; hyphens are converted to underscores)
</quote>
I have no idea about how widely implemented that rule is.
On 9/9/2023 9:18 PM, Arne Vajhøj wrote:
https://sourceforge.net/projects/gnucobol/
<quote>
GnuCOBOL (formerly OpenCOBOL) is a free, modern COBOL compiler.
GnuCOBOL implements a substantial part of the COBOL 85, X/Open COBOL
and newer ISO COBOL standards (2002, 2014, 2023), as well as many
extensions included in other COBOL compilers (IBM COBOL, MicroFocus
COBOL, ACUCOBOL-GT and others).
</quote>
The important part is "X/Open COBOL".
https://pubs.opengroup.org/onlinepubs/009680799/toc.pdf
<quote>
8.10 EXTERNAL NAMES AND CASE CONVENTIONS
...
• working storage items having the EXTERNAL clause (lower-case
letters, digits and
hyphens; hyphens are converted to underscores)
</quote>
I have no idea about how widely implemented that rule is.
So let's see if I now understand this. A bunch of European
Unix System manufacturers decided to break the COBOL language
in a very bad way and everyone is jumping on the band wagon?
Let's hope the majority of serious COBOL programmers avoid this
like the plague.
On 9/9/2023 9:18 PM, Arne Vajhøj wrote:
https://sourceforge.net/projects/gnucobol/
<quote>
GnuCOBOL (formerly OpenCOBOL) is a free, modern COBOL compiler.
GnuCOBOL implements a substantial part of the COBOL 85, X/Open COBOL
and newer ISO COBOL standards (2002, 2014, 2023), as well as many
extensions included in other COBOL compilers (IBM COBOL, MicroFocus
COBOL, ACUCOBOL-GT and others).
</quote>
The important part is "X/Open COBOL".
https://pubs.opengroup.org/onlinepubs/009680799/toc.pdf
<quote>
8.10 EXTERNAL NAMES AND CASE CONVENTIONS
...
• working storage items having the EXTERNAL clause (lower-case
letters, digits and
hyphens; hyphens are converted to underscores)
</quote>
I have no idea about how widely implemented that rule is.
So let's see if I now understand this. A bunch of European
Unix System manufacturers decided to break the COBOL language
in a very bad way and everyone is jumping on the band wagon?
Let's hope the majority of serious COBOL programmers avoid this
like the plague.
On 9/10/2023 9:11 AM, bill wrote:
On 9/9/2023 9:18 PM, Arne Vajhøj wrote:
https://sourceforge.net/projects/gnucobol/
<quote>
GnuCOBOL (formerly OpenCOBOL) is a free, modern COBOL compiler.
GnuCOBOL implements a substantial part of the COBOL 85, X/Open COBOL
and newer ISO COBOL standards (2002, 2014, 2023), as well as many
extensions included in other COBOL compilers (IBM COBOL, MicroFocus
COBOL, ACUCOBOL-GT and others).
</quote>
The important part is "X/Open COBOL".
https://pubs.opengroup.org/onlinepubs/009680799/toc.pdf
<quote>
8.10 EXTERNAL NAMES AND CASE CONVENTIONS
...
• working storage items having the EXTERNAL clause (lower-case
letters, digits and
hyphens; hyphens are converted to underscores)
</quote>
I have no idea about how widely implemented that rule is.
So let's see if I now understand this. A bunch of European
Unix System manufacturers decided to break the COBOL language
in a very bad way and everyone is jumping on the band wagon?
Let's hope the majority of serious COBOL programmers avoid this
like the plague.
I don't know why they did this.
But I could guess that it is because X/Open or Open Group
is very much focused on interoperability.
And names with hyphen are typical not supported in other
languages.
Back to VMS Cobol:
$ typ m3.cob
IDENTIFICATION DIVISION.
PROGRAM-ID.M3.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I-V PIC 9(9) DISPLAY EXTERNAL.
PROCEDURE DIVISION.
MAIN-PARAGRAPH.
MOVE 123 TO I-V
CALL "R3"
STOP RUN.
$ typ r3.c
#include <stdio.h>
#include <string.h>
extern char i_v[9];
void r3()
{
char temp[10];
memcpy(temp, i_v, 9);
temp[9] = 0;
printf("%s\n", temp);
}
$ cob m3
$ cc/extern=common r3
$ link m3 + r3
$ run m3
000000123
i-v is not a valid name in C but i_v is.
Anyway it is a rather weird feature. But let us not forget that
it only came up because Brian made a typo. :-)
On 9/10/2023 1:38 PM, Arne Vajhøj wrote:
On 9/10/2023 9:11 AM, bill wrote:
On 9/9/2023 9:18 PM, Arne Vajhøj wrote:
https://sourceforge.net/projects/gnucobol/
<quote>
GnuCOBOL (formerly OpenCOBOL) is a free, modern COBOL compiler.
GnuCOBOL implements a substantial part of the COBOL 85, X/Open COBOL
and newer ISO COBOL standards (2002, 2014, 2023), as well as many
extensions included in other COBOL compilers (IBM COBOL, MicroFocus
COBOL, ACUCOBOL-GT and others).
</quote>
The important part is "X/Open COBOL".
https://pubs.opengroup.org/onlinepubs/009680799/toc.pdf
<quote>
8.10 EXTERNAL NAMES AND CASE CONVENTIONS
...
• working storage items having the EXTERNAL clause (lower-case
letters, digits and
hyphens; hyphens are converted to underscores)
</quote>
I have no idea about how widely implemented that rule is.
So let's see if I now understand this. A bunch of European
Unix System manufacturers decided to break the COBOL language
in a very bad way and everyone is jumping on the band wagon?
Let's hope the majority of serious COBOL programmers avoid this
like the plague.
I don't know why they did this.
But I could guess that it is because X/Open or Open Group
is very much focused on interoperability.
And names with hyphen are typical not supported in other
languages.
So what? Because C doesn't like it we should change COBOL?
Back to VMS Cobol:
$ typ m3.cob
IDENTIFICATION DIVISION.
PROGRAM-ID.M3.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I-V PIC 9(9) DISPLAY EXTERNAL.
PROCEDURE DIVISION.
MAIN-PARAGRAPH.
MOVE 123 TO I-V
CALL "R3"
STOP RUN.
$ typ r3.c
#include <stdio.h>
#include <string.h>
extern char i_v[9];
void r3()
{
char temp[10];
memcpy(temp, i_v, 9);
temp[9] = 0;
printf("%s\n", temp);
}
$ cob m3
$ cc/extern=common r3
$ link m3 + r3
$ run m3
000000123
i-v is not a valid name in C but i_v is.
Again, so what? Why didn't they change C like they did COBOL?
Anyway it is a rather weird feature. But let us not forget that
it only came up because Brian made a typo. :-)
Feature to some bug to others.
bill
Sysop: | Luis Silva |
---|---|
Location: | Lisbon |
Users: | 763 |
Nodes: | 10 (0 / 10) |
Uptime: | 181:08:24 |
Calls: | 111 |
Files: | 46,971 |
Messages: | 11,239 |