Next: Ternary Operator Definition Example, Previous: Ternary Operator Syntax, Up: Ternary Operators [Index]
Ternary operators are introduced as extensions of binary operators. Their syntax is that of a double binary operator (OPERAND1 mark1 OPERAND2 mark2 OPERAND3) and their definition follows their appearance, with a binary operator definition grouping the first two operands and a second one adding the last operand.
Both binary operator definitions making up a ternary binary definition are of
the struct x1f4_operator_type
kind.
See struct x1f4_operator_type.
The second of them is linked into the first as an extension via a struct
x1f4_2ndscope_type
record pointed to by the extension2
field of the
struct x1f4_operator_type
definition.
See struct x1f4_2ndscope_type.
The extension2
field requires X1f4_E4_E2ND_LINK
bit to be set by
the flags
attribute of the operator definition.
Where a binary operator appears matching the definition (name and list of arguments) of a ternary operator leading operator definition, the two operator definitions are to be combined.
Example: the binary real ‘%’ real operator and the
ternary real ‘%’ real ‘^’ real operator
would be introduced by a single struct x1f4_operator_type
record
matching the binary operator.
Where more ternary operators match in their leading operator definition (name and list of arguments), their definition are to be combined, with their trailing operator definitions following as a table.
Example: the ternary operators real ‘&’ real ‘*’
real and real ‘&’ real ‘*’
integer would be introduced by a single struct
x1f4_operator_type
record.
For ternary operators not sharing their leading binary operator definition, the
trailing definition of the struct x1f4_operator_type
kind is pointed
by the rail
attribute of the struct x1f4_2ndscope_type
extension
record of the leading operator definition. The bits
field of the
extension record sets the X1f4_E4_RAIL_MARK
bit.
For ternary operators sharing their leading binary operator definition, the
trailing definitions of the struct x1f4_operator_type
kind are collected
by a struct x1f4_raillist_type
record, to be pointed by the rail
attribute of the struct x1f4_2ndscope_type
extension record of the
leading operator definition. The bits
field of the extension record
sets the X1f4_E4_RAIL_LIST
bit.
Where the leading binary operator definition does not function as a binary
operator definition too (i.e. there’s no binary operator matching the lead of
the ternary operator) the bits
field of the struct
x1f4_2ndscope_type
extension record sets the X1f4_E4_RAIL_ONLY
bit.
See struct x1f4_raillist_type.
See Operator Second Extension Scope Flags.
All ternary operators introduce a complementary function definition, to which
the operators are expanded. The function definition is to match the operator
definition in number of arguments (3), evaluation and arguments types. The
function is introduced as a regular function extension to the trailing operator
definition, with the X1f4_E4_CALL_LINK
bit not being required.
See Expressive Operators.
The function pointer field in the struct x1f4_operator_type
records
introducing a ternary operator are not interpreted (except where the leading
record is shared with a binary operator definition).
As ternary operators may share their leading operator definition record, they
take most attributes from their second. Included are their precedence (from
priority
), associativity (from bits
) and type (from type
).
The type of the third operand is taken from the second int
in the
args
array of the second operator definition. The first int
is
ignored.
Ternary operators may feature two marks between the second and the third operand, with one of them introduced by the first operator definition record as a suffix mark.
See Postfixed Binary Operators.
Ternary operators define two evaluation precedences, one to the left and
one to the right. The first is taken from the leading operator definition
record, the latter from the trailing operator definition record. The right
precedence ought to be equal or lower than the left precedence (the right
priority
equal or greater than the left priority
).
For ternary operators to evaluate right to left (like the ‘?’‘:’ and the ‘[’‘]’‘=’ operators do) the precedence in the leading operator definition should be higher than that in trailing operator definition.
Next: Ternary Operator Definition Example, Previous: Ternary Operator Syntax, Up: Ternary Operators [Index]