For Programmers: Free Programming Magazines  


Home > Archive > Cobol > September 2004 > Long literals (was: If you were inventing CoBOL...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Long literals (was: If you were inventing CoBOL...
William M. Klein

2004-09-23, 3:55 pm

A slight "clarification" on what Chuck writes below.

There are two separate enhancements in the 2002 Standard that relate to "long
literals"

1) Concatenation operand - uses "&" operator
2) "new-style" quoted literal concatenation, e.g.
"ABC"-
"XYZ"
or
B"01"-
"11"
or
NX"12AB"-
"78EF"

The difference between these two features (both of which are available in both
free and fixed form reference format) is important to understand *IF* one uses
COPY REPLACING or REPLACE statements.

"ABC" & "XYZ" *> is 3 text words
while
"ABC"-
"XYZ" *> is a single text word

***

I certainly would support moving the "old style" quoted literal concatenation to
archaic or obsolete (if done in the 2008 Standard, OBSOLETE would mean that it
would be removed from the 201x Standard <G> ). However, I also think that this
is a VERY commonly used feature (especially by code generators and "alien code
translators" like the IBM mainframe CICS translator's handling of EXEC CICS
statements. Therefore, I wouldn't (personally) expect to see it removed from
many compilers in the next decade or so.

--
Bill Klein
wmklein <at> ix.netcom.com
"Chuck Stevens" <charles.stevens@unisys.com> wrote in message
news:ciscsa$2rj8$1@si05.rsvl.unisys.com...
>
> "Robert Wagner" <robert@wagner.net.yourmammaharvests> wrote in message
> news:rjg1l0lfug8qpt7gh1safepurkvnvqel2j@
4ax.com...
>
>
> I think it's probably moving that way, given the availability of the
> concatenation operator in 2002 COBOL. Personally, though, I think limiting
> the size of a literal produced by the concatenation operator to 160
> characters, as the 2002 standard does, missed the boat.
>
>
> I have. I think concatenation is an improvement, but I also think the
> 160-character limit on literals causes some coding challenges.
>
>
> Mostly those "ways around it" involved declaring data items.
>
> Here's one that involves both continuation and substitution of data spaces:
> INSPECT identifer-1 CONVERTING literal-4 TO literal-5
> where literal-4 and literal-5 each represents the characters in an 8-bit
> character set.
>
> If it were a 7-bit character set in '74 or '85 COBOL you'd still have to use
> continuation to build the literals (you could use the concatenation operator
> in 2002 COBOL). But the maximum size of a literal is still 160 characters
> in 2002 COBOL, so representing the full 256-character set in a single
> literal is prohibited.
>
> This particular construct is one of the reasons for the proposal to increase
> the maximum size of an alphanumeric or national literal in the 2008 draft.
>
> If the implementor was able to make proper use of the "structured constant"
> mechanism also proposed for the 2008 draft, it's possible that
> INSPECT identifier-1 CONVERTING structured-constant-1 TO
> structured-constant-2
> could be done with no more overhead than the literal-to-literal case, but
> unless that's the case if you're going to avoid continuation there's almost
> certainly going to be two instantiations of each of the character sets
> somewhere in the program memory!
>
> -Chuck Stevens
>
>



William M. Klein

2004-09-23, 3:55 pm

typo

> 2) "new-style" quoted literal concatenation, e.g.


should have been

> 2) "new-style" quoted literal continuation, e.g.


--
Bill Klein
wmklein <at> ix.netcom.com
"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:oLm4d.1886960$y4.325077@news.easynews.com...
>A slight "clarification" on what Chuck writes below.
>
> There are two separate enhancements in the 2002 Standard that relate to "long
> literals"
>
> 1) Concatenation operand - uses "&" operator
> 2) "new-style" quoted literal concatenation, e.g.
> "ABC"-
> "XYZ"
> or
> B"01"-
> "11"
> or
> NX"12AB"-
> "78EF"
>
> The difference between these two features (both of which are available in both
> free and fixed form reference format) is important to understand *IF* one uses
> COPY REPLACING or REPLACE statements.
>
> "ABC" & "XYZ" *> is 3 text words
> while
> "ABC"-
> "XYZ" *> is a single text word
>
> ***
>
> I certainly would support moving the "old style" quoted literal concatenation
> to archaic or obsolete (if done in the 2008 Standard, OBSOLETE would mean that
> it would be removed from the 201x Standard <G> ). However, I also think that
> this is a VERY commonly used feature (especially by code generators and "alien
> code translators" like the IBM mainframe CICS translator's handling of EXEC
> CICS statements. Therefore, I wouldn't (personally) expect to see it removed
> from many compilers in the next decade or so.
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com
> "Chuck Stevens" <charles.stevens@unisys.com> wrote in message
> news:ciscsa$2rj8$1@si05.rsvl.unisys.com...
>
>



William M. Klein

2004-09-28, 3:55 am

typo

> 2) "new-style" quoted literal concatenation, e.g.


should have been

> 2) "new-style" quoted literal continuation, e.g.


--
Bill Klein
wmklein <at> ix.netcom.com
"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:oLm4d.1886960$y4.325077@news.easynews.com...
>A slight "clarification" on what Chuck writes below.
>
> There are two separate enhancements in the 2002 Standard that relate to "long
> literals"
>
> 1) Concatenation operand - uses "&" operator
> 2) "new-style" quoted literal concatenation, e.g.
> "ABC"-
> "XYZ"
> or
> B"01"-
> "11"
> or
> NX"12AB"-
> "78EF"
>
> The difference between these two features (both of which are available in both
> free and fixed form reference format) is important to understand *IF* one uses
> COPY REPLACING or REPLACE statements.
>
> "ABC" & "XYZ" *> is 3 text words
> while
> "ABC"-
> "XYZ" *> is a single text word
>
> ***
>
> I certainly would support moving the "old style" quoted literal concatenation
> to archaic or obsolete (if done in the 2008 Standard, OBSOLETE would mean that
> it would be removed from the 201x Standard <G> ). However, I also think that
> this is a VERY commonly used feature (especially by code generators and "alien
> code translators" like the IBM mainframe CICS translator's handling of EXEC
> CICS statements. Therefore, I wouldn't (personally) expect to see it removed
> from many compilers in the next decade or so.
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com
> "Chuck Stevens" <charles.stevens@unisys.com> wrote in message
> news:ciscsa$2rj8$1@si05.rsvl.unisys.com...
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com