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.
>>-| 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 |-)-'
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.
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)
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