Re: replace statement and free format

From: William M. Klein (wmklein_at_nospam.netcom.com)
Date: 04/26/04


Date: Mon, 26 Apr 2004 20:02:43 GMT

Herwig (and group),
   There are some (medium good) reasons that the Standard (2002 AND earlier)
doesn't say much about "listings". Most importantly because their are both
historical and current reasons why programmers in one environment expect/want
VERY different things than those in other situations. Before giving some
opinions on your specific questions, let me outline why this is even more of a
problem that you state below.

For those who don't know, the Standard has never even required (and still
doesn't) that a vendor PRODUCE a compile-time listing of the source code. In
the 2002 Standard, there is some new stuff (Directive and option on the COPY
statement) that allows one to turn off listing *if* the vendor produces any at
all - but other than that, it is pretty quiet.

Issues:

1) Free form reference format allows for each source line to have 255 characters
*NOT* "bytes". Therefore, if every other character on your line is UCS-4 while
the others are single byte alphanumeric *and* you need a single byte between
changes of character sets, you could have 255 x 7 = 1785 bytes on a single line
of source code.!!! Now tell me what medium is "good" for display such a line <G>

2) I can think of (at least) 3 reasons why programmers would want "listings" -
and each of these would "suggest" different answers to how you would want your
listings to appear.

  A) for "finding and fixing" compiler errors (and warnings)
  B) for "finding and fixing" run-time errors
  C) for "audit trails" and "researching" existing production programs

3) I was surprised when I was working on the 2002 Standard that neither the old
or the new Standard said anything about what to put in listings when a
REPLACING/REPLACE took place. Should it show the "original" source code or the
"derived" source code. I was even MORE surprised (because I was used to one way
of doing this) that there actually ARE some current compilers that work each
way - and for each way of working, the users are CONVINCED that "their way" is
best.

4) One of the "design" points of the new free form reference format is that it
is POSSIBLE to create valid source code that will compile with EITHER free or
fixed form reference format - so that such source code can be used in COPY
members - without modification. This is possible if you obey the following
rules:

  A) only include source code between column 8 and the R-margin (whatever it is
in your compiler)
  B) use the new (rather than old) methods for alphanumeric (and national)
literal continuation
  C) use directives (not old fashion) debugging indicators, comment indicators,
and page eject directives
  D) never continue a COBOL word across lines
  E) do not put any data (comments) between the R-margin and end-of-source-line
(Columns 73-80 in many existing implementations)

***

Given what I have said above, the following is what I would like to see from a
vendor in the "best of all possible worlds"

1) Provide two "basic" options for listings:
     - for compiler error fixing (showing code exactly as entered)
    - for run-time debugging (showing "derived" source code after
REPLACE/REPLACING

2) For "source code" listing
   - do NOT show source code AFTER replace/replacing (or if you do - show it as
comments). This will get "correct" line numbers and show the programmer EXACTLY
what they entered.
  - Provide two suboptions: One for source code that is ALL in fixed form
reference format (and will print/display in a "standard length" medium - and
   another method for free format reference format or mixed reference format -
where you will have to figure out what to do with VERY long lines (up to 1785
bytes as listed above - or even longer if you use different UTF/UCS national
character sets).
 - Depending on how many "passes" your compiler does of source code, either
issue an error message or a warning message if the programmer SAYS their source
code is all "fixed format" but they actually include some free format source
code. (If your compiler does multiple passes, you should be able to turn on the
"free format" listing even if they told you it was all fixed format reference
format)

3) For run-time debugging - show the code in FREE FORMAT reference format always
and after REPLACE/REPLACING (i.e convert it to the "restricted" format that I
described above, e.g. using new-style continuation and directives rather than
column-7 "stuff). You may want to give the programmer a "choice" of how long
you want each listing line to be - only as long as your "R-Margin" fixed format
is - or say 132 (for a typical "old-style" printer) or some length that looks
"good" on a screen in your environment.

4) If your current ('85 Standard) compiler shows listings AFTER doing
REPLACE/REPLACING, then you should give the programmer a choice of whether they
want to have the listing show before (with after as a comment) - or after (with
before as a comment) - or just one or the other. Personally, I can see
advantages and disadvantages (for fixing compile-time errors) with either
approach.

   ***

I know that the "recommendations" (personal opinions) given above might be a LOT
of work for a vendor, but I think it would "pay off" in the long run in doing
both compile-time and run-time "fixes".

Let me know if any of this isn't clear.

-- 
Bill Klein
 wmklein <at> ix.netcom.com
"Herwig Huener" <Herwig.Huener@fujitsu-siemens.com> wrote in message
news:c6j1j7$eb8$1@nntp.fujitsu-siemens.com...
> 2004-04-26 15:07:00 MEST
>
> I have implemented free format in the
> BS2000 COBOL Compiler. What's still
> missing is the use of the "replace"
> statement in free format, on which I
> work now. Now we found a few points
> which are not quite clear from the
> COBOL-Standard.
>
> Consider a replace-statement given
> in fixed format, and it is used
> in a part of the code where free
> format is in effect. As far as the
> generation of code is concerned, there
> is no problem, because the Standard
> says, everything should be converted
> to free format, or a compiler should
> behave as if he actually did this.
>
> But what shall be the effect on the
> listing? As this is implementor-defined,
> one should ask the COBOL community about
> the best way.
>
> An example:
>
> ...
> ...
> ...
>
>            replace ==q== by                     ==add 1 to r. display "1
>       -                                                               "2
>       -                                                               "3
>       -                                                               "4
>       -                                                               "5
>       -                                                              "67
>       -                                                               "8
>       -                                                             "901
>       -                                                               "2
>       -                                                              "34
>       -                                                               "5
>       -                                                              "67
>       -                                                               "8
>       -                                                              "90
>       -                                                               "1
>       -                                                             "234
>       -                                                      "5678901234
>       -                                                              "56
>       -                                                              "78
>       -                                                              "90
>       -                                                              "12
>       -                                                              "34
>       -                                                 "567890123456789
>       -"0" upon tv. add 1 to s.==.
>
>        >> source format is free
>
> *> The next line has a length of 255:
> q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q
> q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q
> q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q
> q q q q q q q q q q q q q
>
> >> source format is fixed
>
> ...
> ...
> ...
>
> End of this example.
>
> Now, for the purpose of a listing, shall the replace-text be
> converted to free format, shall the replace be applied and
> the result be wraped around because the resulting line has
> a length of a few thousand characters?
>
> Or shall the replace-text be taken as it is, repeatedly
> replaced into the "... q q q q ..." line, thus providing
> a sort of fixed-format code in a place where actually
> free format is in effect?
>
> A third serious suggestion I have heard is that the
> compiler inserts brackets of
>        >> source format is free
> >> source format is fixed
> in such cases, maybe properly marked as compiler-generated.
>
> Should a compiler generate a warning when crossover
> - replaces are used?
>
> One may find good reasons for any of these strategies.
>
> Confused. Herwig
>
>


Relevant Pages

  • Re: Understanding Error Messages
    ... The listing you can see my listing in: ... you fix mainframe compile problems by fixing the mainframe source code ... Finally, just like you are using a 15 year old compiler on the PC, you are also ...
    (comp.lang.cobol)
  • Re: MsDos COM file format
    ... We would like to make a compiler as an exercise and the COM format seems ... source code now to freshen up my mind and I found a remark that long ...
    (comp.lang.asm.x86)
  • Re: skip an item to WRITE using a FORMAT
    ... > where fmt_skip tells the compiler to skip printing ivec. ... > source code. ... The FORMAT can be a character variable, which of course you can read ... Or am I missing something? ...
    (comp.lang.fortran)
  • Re: RAW vs JPEGs - Does RAW show more detail?
    ... format being used, they will all be available forever. ... Every time a new sensor comes out with its associated storage format in RAW, the c code needs to be updated with the definition for it, specific-to-type algorithms and then recompiled. ... A recent version set of dcraw.c source code has over 7000 lines of code dedicated to a plethora of sensors/models! ... filters = 0x16161616; ...
    (rec.photo.digital.slr-systems)
  • Re: vm02 update
    ... Instant Pascal was a misguided attempt at creating an IDE with automatic formatting and almost instant feedback. ... Editing the source in a tokenized format would keep the memory constraints lower and ease the first pass of the compiler. ... compiled to machine code at all. ...
    (comp.sys.apple2.programmer)

Loading