Restricted expressions

Where PL/I requires a (possibly signed) constant, a restricted expression can be used.

A restricted expression is an expression whose value is calculated at compile time and used as a constant. For example, you can use expressions to define constants required for the following:
A restricted expression is identical to a normal expression but requires that each operand be one of the following:

Examples

  dcl Max_names fixed bin value (1000),
      Name_size fixed bin value (30),
      Addr_size fixed bin value (20),
      Addr_lines fixed bin value (4);
  dcl 1 Name_addr(Max_names),
        2 Name char(Name_size),
        2 * union,
          3 Address char(Addr_lines*Addr_size), /* address    */
          3 addr(Addr_lines) char(Addr_size),
        2 * char(0);
  dcl One_Name_addr char(size(Name_addr(1)));   /* 1 name/addr*/
  dcl Two_Name_addr char(length(One_Name_addr)
                         *2);                /* 2 name/addrs  */
  dcl Name_or_addr char(max(Name_size,Addr_size)) based;

  dcl Ar(10) pointer;
  dcl Ex     entry( dim(lbound(Ar):hbound(Ar)) pointer);
  dcl Identical_to_Ar( lbound(Ar):hbound(Ar) ) pointer;

If you change the value of any of the named constants in the example, all of the dependent declarations are automatically reevaluated.






Published: 23 December 2018