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

RE: COBOL compiler



On Tue, 2003-08-26 at 21:42, David Turetsky wrote:
> 
> 
> On Tue, 2003-08-26 at 13:29, David Turetsky wrote:
> > 
[snip]
> > Here's a simplistic example of how COBOL is specialized:
> > Say we have 2 record definitions:
> > 01  A-SMALL-REC.
> >     05  FIRST-NAME         PIC X(15).
> >     05  LAST-NAME          PIC X(15).
> > 01  A-LARGE-REC.
> >     05  HONORIFIC          PIC X(5).
> >     05  FIRST-NAME         PIC X(15).
> >     05  MIDDLE-I           PIC X.
> >     05  LAST-NAME          PIC X(15).
> >     05  MODIFIER           PIC X(5).
> > 
> > MOVE 'JOHN' TO A-SMALL-REC.FIRST-NAME.
> > MOVE 'DOE' TO A-SMALL-REC.LAST-NAME.
> > MOVE SPACES TO A-LARGE-REC.
> > 
> > MOVE CORRESPONDING A-SMALL-REC TO A-LARGE-REC.
> > 
> > Here, A-SMALL-REC.FIRST-NAME and A-SMALL-REC.LAST-NAME will be
> > moved to the corresponding fields in A-LARGE-REC.
> > In such a trivial example, so what?  If, however, there are many
> > fields in A-SMALL-REC, then MOVE CORRESPONDING is a big coding
> > time-saver, and ensures that if the records definitions ever
> > change, the code will still work.
> > 
> > 
> 
> You may or may not be correct in your assessment, but I do not believe
> the above example particularly supports that view
> 
> If the "MOVE CORRESPONDING..." is recurring, you would write a
> subroutine. If not, it's a one-time task, facilitated by a good editor
> 
> use Class::Struct
> 
> struct SmallRec  => {
>    first-name    => '$',
>    last-name     => '$',
> }
> 
> struct LargeRec  => {
>    honorific     => '$',
>    first-name    => '$',
>    middle-i      => '$',
>    last-name     => '$',
>    modifier      => '$',
> }
> 
> $ASR = SmallRec->new();
> $ASR->first-name('John');
> $ASR->last-name('Doe');
> 
> $ALR = LargeRec->new();
> $ALR->first-name($ASR->first-name);
> $ALR->last-name($ASR->last-name);

And if you add new fields, you must add more assignment statements.
A small thing, sure, but in a big program, the small things add
up.

> Seems like a one-to-one correspondence to me, never mind the compactness
> and power of Perl

I'd still rather the MOVE CORRESPONDING, because it means that 
one more bit of busy work is off my plate.

A corollary command is, if I remember properly, the FILL verb.
If your record in full of a mixture of text, packed decimal and
binary fields, you simply say "FILL THE-RECORD.", and the compiler
decides whether to move spaces or zeros to each field, as appro-
priate.

Again, yes, the same effect *can* be done in Perl, C, Python, 
Pascal, etc, but again, it's just one less thing that I have to
worry about, using COBOL.

-- 
-----------------------------------------------------------------
Ron Johnson, Jr. ron.l.johnson@cox.net
Jefferson, LA USA

"What other evidence do you have that they are terrorists, other 
than that they trained in these camps?"
17-Sep-2002 Katie Couric to an FBI agent regarding the 5 men 
arrested near Buffalo NY



Reply to: