ASSIGNABLE and NONASSIGNABLE attributes

The ASSIGNABLE and NONASSIGNABLE attributes specify whether the associated variable can be the target of an assignment.

Read syntax diagramSkip visual syntax diagramASSIGNABLENONASSIGNABLE

Abbreviations: ASGN, NONASGN

Default: ASSIGNABLE

If a variable has the NONASSIGNABLE attribute, the variable cannot be assigned.

If an entry descriptor has the NONASSIGNABLE attribute, the argument is assumed not to change when the associated ENTRY is invoked. If the argument is a constant, no dummy argument is created.

The ASSIGNABLE and NONASSIGNABLE attributes are propagated to members of structures or unions.

Passing a variable that has the NONASSIGNABLE attribute as an argument to an entry when the corresponding parameter has the ASSIGNABLE attribute allows the variable to be modified which would make the code invalid. For example, the following code could lead to a protection exception:

     call test( 17 );

     test: proc( x );
       dcl x fixed bin(31) NONASSIGNABLE;
       dcl e ext entry( ASSIGNABLE fixed bin(31) );
       call e(x);
     end;