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

Re: [GNU-COBOL] PIC -> edit masks -> a standardlargenumericrepresentation



Boris Kortiak wrote:
...
> Right, me throwing around structure sizes is premature.  The idea
> I want to get across is to have a base type with two pieces,
> one to hold data and one to hold type, in order to simplify other
> parts as much as possible.  Based on the remarkable ease the "perl
> scalar" (or a Lisp token) offers in comparison with the umpteen+
> different incompatable types one has to finesse in C. (or asm.)
> 
Good idea. So the runtimes get passed the data and the
descriptors. I have seen cobol compilers do this.
> BK-
> Ok, lets kick around some ideas for this thing...
> 
> 1) Primary division of data types is OTHER|EDITED
> 2) OTHER breaks down into ALPHABETIC|ALPHANUMERIC|NUMERIC
> 3) ALPHABETIC { PIC A(n) } only needs length parameter
> 4) ALPHANUMERIC { PIC X(n) } only needs length paramenter
> 5) NUMERIC breaks down into DISPLAY|COMPUTATIONAL
> 6) DISPLAY breaks down into WHOLE|DECIMAL|SCALAR
> 7) WHOLE { PIC 9(n) } only needs length
> 8) DECIMAL { PIC 9(n)v9(n) } needs length and decimal point information
> 9) SCALAR { PIC [9(n)P(n)|P(n)9(n) } needs length and decimal point information
> 10) SCALAR can be combined with WHOLE
> 11) SCALAR can be combined with DECIMAL

This is good.

There are varants of comp and in most compilers comp-1 is float
comp-2 is double. Then there is usage packed.

I would amalgamate decimal and scalar. But to these you need to
add some data about the sign, leading trailing or none.

Something like:

struct data_desc_struct {
   enum data_type; /* numeric, edited, alphabetic, alphanumeric
*/  
   union details {
      struct alpha_details {
        int length;
      } alph;
      struct numeric_details {
      enum usage; /* binary, packed, float, double, bytes, basic
binary */
      int length; /* for packed and byte decimal, means digits,
else # bytes */
      enum sign_loc; /* none, leading, trailing, leading
overpunch, trailing overpunch field not always used */
      int decimal_point_posn; /* 0 = implicit after last digit 1
means one digit earlier etc *field not always used */	
      } num;
      struct editing_details {
      char * edit_string;
      } ed;
   } det;
}

--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.