RE: COBOL compiler
On Tue, 2003-08-26 at 13:29, David Turetsky wrote:
>
> Yes, but how does that compare with similarly powerful features in
Perl?
> I *knew* someone would ask about the Programmable Extraction and
> Reporting Language...
>
> Please don't think that I am implying that Perl or C are bad
languages.
> I certainly wouldn't write a logfile analyzer in COBOL.
>
> For my knowledge, how would Perl sort the contents of a file,
> allowing the programmer to use a complex algorithm as an
> input filter, and then take the output stream, processing it
> 1 record at a time, without needing to write to and then read
> from temporary files with all of the extra SLOC that that entails?
>
> One thing that I don't think that any of the "modern" languages
> do, without extra libraries and function calls, is BCD arithmatic.
>
> 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);
Seems like a one-to-one correspondence to me, never mind the compactness
and power of Perl
--
David
Reply to: