Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

DEFAULT statement

The DEFAULT statement specifies data-attribute defaults (when attribute sets are not complete). Any attributes not applied by the DEFAULT statement for any partially-complete explicit or contextual declarations, and for implicit declarations, are supplied by language-specified defaults.

The DEFAULT statement overrides all other attribute specifications, except that a name declared with the ENTRY or FILE attribute, but none of the attributes that would imply the VARIABLE attribute, will be given the implicit CONSTANT attribute by PL/I before any DEFAULT statements are applied. Consequently, in the following example, PL/I gives Xtrn the CONSTANT attribute and not the STATIC attribute.

  Sample: proc;

    default range(*) static;
    dcl Xtrn entry;

  end;

Structure and union elements are given default attributes according to the name of the element, not the qualified element name. The DEFAULT statement cannot be used to create a structure or a union.

Read syntax diagramSkip visual syntax diagram>>-DEFAULT------------------------------------------------------>
 
   .-,---------------------------------------------------.
   V                                                     |
>----RANGE--(-| identifiers |-)--attribute-specification-+--;--->
 
                       .-,---------------------------.
                       V                             |
>--| identifiers: |--+---identifier--+-------------+-+-+-------><
                     |               '-:identifier-'   |
                     '-*-------------------------------'
 

Abbreviation: DFT

RANGE( identifier )
Specifies that the defaults apply to names that begin with the same letters as in the identifier specified. For example:
RANGE (ABC)
applies to these names:
ABC
ABCD
ABCDE
but not to:
ABD
ACB
AB
A
Hence a one-letter identifier in the range-specification applies to all names that start with that letter. The RANGE identifier may be specified in DBCS.
RANGE( identifier : identifier )
Specifies that the defaults apply to names with initial letters that either match the two identifiers specified or fall between the two in alphabetic sequence. The letters may be in DBCS, but in determining if a RANGE specification applies to a name, all comparisons are based solely on the hex values of the letters involved. The letters given in the specification must be in increasing alphabetic order. For example:
RANGE(A:G,I:M,T:Z)
RANGE(*)
Specifies all names in the scope of the DEFAULT statement. For example:
DFT RANGE (*) PIC '99999';

This statement specifies default attributes REAL PICTURE '99999' for all names.

An example of a factored-specification with the range options is:

DEFAULT (RANGE(A)FIXED, RANGE(B)
        FLOAT)BINARY;

This statement specifies default attributes FIXED BINARY for names with the initial letter A, and FLOAT BINARY for those with the initial letter B.

DESCRIPTORS

Specifies that the attributes are included in any parameter descriptors in a parameter descriptor list of an explicit entry declaration, provided that:

For example:

DEFAULT DESCRIPTORS BINARY;
DCL X ENTRY (FIXED, FLOAT);

The attribute BINARY is added to each parameter descriptor in the list, producing the equivalent list:

(FIXED BINARY, FLOAT BINARY)
attribute-list
Specifies a list of attributes from which selected attributes are applied to names in the specified range. Attributes in the list can appear in any order and must be separated by blanks.

Only those attributes that are necessary to complete the declaration of a data item are taken from the list of attributes.

If FILE is used, it implies the attributes VARIABLE and INTERNAL.

The dimension attribute is allowed, but only as the first item in an attribute specification. The bounds can be specified as an arithmetic constant or an expression and can include the REFER option. For example:

DFT RANGE(J) (5);
DFT RANGE(J) (5,5) FIXED;

Although the DEFAULT statement can specify the dimension attribute for names that have not been declared explicitly, a subscripted name is contextually declared with the attribute BUILTIN. Therefore, the dimension attribute can be applied by default only to explicitly declared names.

The INITIAL attribute can be specified.

Attributes that conflict, when applied to a data item, do not necessarily conflict when they appear in an attribute specification. For example:

DEFAULT RANGE(S) BINARY VARYING;

This means that any name that begins with the letter S and is declared explicitly with the BIT, CHARACTER, or GRAPHIC attribute receives the VARYING attribute; all others (that are not declared explicitly or contextually as other than arithmetic data) receive the BINARY attribute.

VALUE
Can appear anywhere within an attribute-specification except before a dimension attribute.

VALUE establishes any default rules for an area size, string length, and numeric precision.

In a DEFAULT statement, the VALUE option is the only place where an area size, string length or numeric precision may be specified.

These size, length and precision specifications in a VALUE clause are applied after the system default attributes, but before the system defaults for size, length and precision. So, for example, given DCL I; and DEFAULT RANGE(*) VALUE( FIXED BIN(31) );, the variable I will receive the system default attributes of FIXED BIN, but the precision 31 from the VALUE option (rather than the system default of 15).

The size of AREA data, or length of BIT, CHARACTER, or GRAPHIC data, can be an expression or an integer and can include the REFER option, or can be specified as an asterisk.

For example:

DEFAULT RANGE(A:C)
        VALUE (FIXED DEC(10),
              FLOAT DEC(14),
              AREA(2000));
DECLARE B FIXED DECIMAL,
        C FLOAT DECIMAL,
        A AREA;

These statements are equivalent to:

DECLARE B FIXED DECIMAL(10),
        C FLOAT DECIMAL(14),
        A AREA(2000);

The base and scale attributes in value-specification must be present to identify a precision specification with a particular attribute. The base and scale attributes can be factored (see Factoring attributes).

The only attributes that the VALUE option can influence are area size, string length, and precision. Other attributes in the option, such as CHARACTER and FIXED BINARY in the above examples, merely indicate which attributes the value is to be associated with. Consider the following example:

DEFAULT RANGE(I) VALUE(FIXED DECIMAL(8,3));
I = 1;

If it is not declared explicitly, I is given the language-specified default attributes FIXED BINARY(15,0). It is not influenced by the default statement, because this statement specifies only that the default precision for FIXED DECIMAL names is to be (8,3).

For example:

DFT RANGE(*) VALUE(FIXED BINARY(31));

specifies precision for identifiers already known to be FIXED BINARY, while

DFT RANGE(*) FIXED BINARY VALUE(FIXED BINARY(31));

specifies both the FIXED BINARY attribute as a default and the precision.

There can be more than one DEFAULT statement within a block. The scope of a DEFAULT statement is the block in which it occurs, and all blocks within that block which neither include another DEFAULT statement with the same range, nor are contained in a block having a DEFAULT statement with the same range.

A DEFAULT statement in an internal block affects only explicitly declared names. This is because the scope of an implicit declaration is determined as if the names were declared in a DECLARE statement immediately following the PROCEDURE statement of the external procedure in which the name appears.

It is possible for a containing block to have a DEFAULT statement with a range that is partly covered by the range of a DEFAULT statement in a contained block. In such a case, the range of the DEFAULT statement in the containing block is reduced by the range of the DEFAULT statement in the contained block. For example:

 P:  PROCEDURE;
L1:  DEFAULT RANGE (XY) FIXED;
 Q:  BEGIN;
L2:  DEFAULT RANGE (XYZ) FLOAT;
     END P;

The scope of DEFAULT statement L1 is procedure P and the contained block Q. The range of DEFAULT statement L1 is all names in procedure P beginning with the characters XY, together with all names in begin-block Q beginning with the characters XY, except for those beginning with the characters XYZ.

Labels can be prefixed to DEFAULT statements. A branch to such a label is treated as a branch to a null statement. Condition prefixes cannot be attached to a DEFAULT statement.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)