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

Expressions and references

Order of evaluation
Targets
Variables
Pseudovariables
Intermediate results
Operational expressions
Pointer Operations
Arithmetic operations
Bit operations
Comparison operations
Concatenation operations
Combinations of operations
Array expressions
Prefix operators and arrays
Infix operators and arrays
Structure expressions
Restricted expressions
Examples

This chapter discusses the various types of expressions and references.

An expression is a representation of a value. An expression can be one of the following:

An expression that contains operators is an operational expression. The constants and variables of an operational expression are called operands. See Operational expressions for more information.

The following diagram shows the syntax for expressions and references.

Read syntax diagramSkip visual syntax diagram>>-| unary-expression |----------------------------------------->
 
   .-----------------------------------------.
   V                                         |
>----+-------------------------------------+-+-----------------><
     |                (1)                  |
     '-infix-operator-----unary-expression-'
 
unary-expression:
 
   .--------------------------.
   V                          |
|----+----------------------+-+--| elementary-expression |------|
     |                 (1)  |
     '-prefix-operator------'
 
elementary-expression:
 
|--+-(expression)--+--------------------------------------------|
   +-| reference |-+
   '-constant------'
 
reference:
 
|--+----------------------------+--| basic-reference |---------->
   |                       (2)  |
   '-| locator-qualifier |------'
 
>--+-----------------------------+------------------------------>
   |                      (3)    |
   '-(-| subscript-list |------)-'
 
   .--------------------------------.
   V                                |
>----+----------------------------+-+---------------------------|
     |                     (4)    |
     '-(-| argument-list |------)-'
 
locator-qualifier:
 
    (2)
|---------reference--+- -> -+-----------------------------------|
                     +- => -+
                     '- . --'
 
basic-reference:
 
                                                (6)
|--+------------------------------+--identifier-----------------|
   |                         (5)  |
   '-| qualified-reference |------'
 
subscript-list:
 
          .-,--------------.
    (3)   V                |
|-----------+-expression-+-+------------------------------------|
            '-*----------'
 
argument-list:
 
          .-,--------------.
    (4)   V                |
|-----------+-expression-+-+------------------------------------|
            '-*----------'
 
qualified-reference:
 
    (5)
|---------basic-reference--+------------------------+--.--------|
                           '-(-| subscript-list |-)-'
 

Notes:
  1. Operators are shown in Table 6.
  2. Locator-qualifier is described under Locator qualification and Typed structure qualification.
  3. Subscripts are described under Arrays.
  4. Arguments are described in Passing arguments to procedures.
  5. Qualified-reference is described under Structure/union qualification.
  6. Identifiers are described under Identifiers.

Any expression can be classified as an element expression (also called a scalar expression), an array expression, or a structure expression. Element variables and array variables can appear in the same expression.

An element expression
represents a single value. This definition includes an elementary name within a structure or a union or a subscripted name that specifies a single element of an array.
An array expression
represents an array of values. This definition includes a member of a structure or union that has the dimension attribute.
A structure expression
represents a structured set of values.

Given the following example:

  dcl A(10,10) bin fixed(31),
      B(10,10) bin fixed(31),
      1 Rate,
        2 Primary dec fixed(4,2),
        2 Secondary dec fixed(4,2),
      1 Cost(2),
        2 Primary dec fixed(4,2),
        2 Secondary dec fixed(4,2),
      C bin fixed(15),
      D bin fixed(15);
  dcl Pi bin float value(3.1416);

These are element expressions:

  Pi
  27
  C
  C * D
  A(3,2) + B(4,8)
  Rate.Primary - Cost.Primary(1)
  A(4,4) * C
  Rate.Secondary / 4
  A(4,6) * Cost.Secondary(2)
  sum(A)
  addr(Rate)

These are array expressions:

  A
  A + B
  A * C - D
  B / 10B

The syntax of many PL/I statements allows expressions, provided the result of the expression conforms with the syntax rules. Unless specifically stated in the text following the syntax specification, the unqualified term expression or reference refers to a scalar expression. For expressions other than a scalar expression, the type of expression is noted. For example, the term array expression indicates that a scalar expression is not valid.

An example of a structure expression is:

  Rate = Rate*2

Terms of use | Feedback

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