<Syntax> |
|
|
|
INTERFACE OPERATOR ( operator )
operator ::= + | - | * | / | ** | == | /= |
< | <= | > | >= | // | .AND. |
.OR. | .EQV. | .NEQV. | .NOT. | user-operator
user-operator ::= .letter[letter...].
A user-operator can have any sequence of letters that does not match an intrinsic operator.
|
|
|
|
|
|
<Semantics> |
|
|
|
The INTERFACE OPERATOR statement is an INTERFACE statement that begins a generic interface block.
It declares (additional) specific procedures for the specified operator.
The .NOT. operator is a unary operator, the + and - operators are both unary and binary operators,
and all other intrinsic operators are binary operators.
User-defined operators may be both unary and binary operators.
A procedure that implements a unary operator shall be a function with exactly one argument, and that argument shall have INTENT(IN).
A procedure that implements a binary operator shall be a function with exactly two arguments, and both arguments shall have INTENT(IN).
When an expression contains
operator expression
and expression matches the argument of a specific procedure F1 that implements that unary operator,
that subexpression is evaluated as if it had been written
F1 ( expression )
When an expression contains
expression operator expression
and the first expression matches the first argument of a specific procedure F2 that implements that binary operator,
and the second expression matches the second argument of F2,
that subexpression is evaluated as if it had been written
F2 ( expression , expression )
Note: An operator procedure cannot replace any intrinsic operation, so things like "3+4" always have their intrinsic meaning.
(But "3+.false." is not an intrinsic operation, and could be provided by an operator procedure.)
It is important to be careful (and use parentheses) in expressions containing user-defined operators.
All operators have their normal precedence whether they are providing an intrinsic operation or referencing an operator procedure.
Also, unary user-operators have the highest precedence (higher than **),
and binary user-operators have the lowest precedence (lower than .EQV. and .NEQV.).
|
|
|
|
|
|
<Related> |
|
|
|
END INTERFACE statement,
INTERFACE statement,
INTERFACE ASSIGNMENT statement,
MODULE PROCEDURE statement |
|
|