Operator precedence: Difference between revisions
Standardize Pascal, allegedly adding new external links [spam detection false positive]
Drkameleon (talk | contribs) |
(Standardize Pascal, allegedly adding new external links [spam detection false positive]) |
||
Line 16:
=={{header|8th}}==
In 8th it's very simple: the currently invoked word has precedence, and items are operated upon in the order they are popped off the stack.
=={{header|6502 Assembly}}==
There are two types of indirect addressing: Indirect X and Indirect Y. These differ in that the indirect X mode applies the offset before looking up the address.
Line 849 ⟶ 850:
|}
=={{header|Delphi}}==
See table at [[#Free Pascal|Free Pascal]].
=={{header|Eiffel}}==
Line 1,191 ⟶ 1,193:
|}
=={{header|Free Pascal}}==
{| class="wikitable" style="margin: auto;"▼
|+ operator precedence in FreePascal
! operator !! precedence !! category
|-▼
| <code>not</code>, unary <code>+</code>, unary <code>-</code>, <code>@</code>, <code>**</code> || highest (first) || unary operators, power
|-
| <code>*</code>, <code>/</code>, <code>div</code>, <code>mod</code>, <code>and</code>, <code>shl</code>, <code>shr</code>, <code>as</code>, <code><<</code>, <code>>></code>, <strike><code>is</code> [until FPC 3.3.1]</strike>
| second
| multiplying operators
|-
| <code>+</code>, <code>-</code>, <code>or</code>, <code>xor</code>, <code>><</code>
| third
| adding operators
|-
| <code>=</code>, <code><></code>, <code><</code>, <code>></code>, <code><=</code>, <code>>=</code>, <code>in</code>, <code>is</code> [since FPC 3.3.1]
| lowest
| relational operators
|}
“[B]inary operators of the same precedence are left-associative.”
Nevertheless, “[t]he order in which expressions of the same precedence are evaluated is not guaranteed to be left-to-right.”
(quotes from the Free Pascal Reference Guide)
The default configuration sets <code>{$boolEval off}</code> (<code>{$B-}</code> for short).
This enables “lazy evaluation” and thus affects evaluation order.
One notable difference to standardized [[#Pascal|Pascal]] in operator precedence can be switched:
Normally, Free Pascal’s unary minus is at the highest precedence level.
With <code>{$modeSwitch ISOUnaryMinus+}</code>, which is enabled by default in <code>{$mode ISO}</code> and <code>{$mode extendedPascal}</code>, unary minus can be put at the same level as all other adding operators (like the ISO standards define).
=={{header|Furor}}==
Line 1,913 ⟶ 1,945:
=={{header|Pascal}}==
Standard Pascal, as laid out in ISO standard 7185, recognizes four precedence levels.
Extended Pascal (EP), defined in ISO standard 10206, has one additional level, [[Exponentiation with infix operators in (or operating on) the base#Pascal|exponentiating operators]].
▲{| class="wikitable"
The following is a consolidated table for both standards:
{| class="wikitable" style="margin: auto;"
|+ operator precedence in Pascal
! class !! operators
|-
|
|-
| exponentiating operators ||
* <code>**</code> (only in EP)
* <code>pow</code> (only in EP)
|-
| multiplying operators ||
* <code>*</code>
* <code>/</code>
* <code>div</code>
* <code>mod</code>
* <code>and</code>
* <code>and_then</code> (only available in EP)
|-
|
* <code>+</code>
* <code>-</code>
* <code>><</code> (only in EP)
* <code>or</code>
* <code>or_else</code> (only available in EP)
|-
| relational operators ||
* <code>=</code>
▲|-
* <code><></code>
* <code><</code>
* <code>></code>
* <code><=</code>
* <code>>=</code>
* <code>in</code>
|}
“Sequences of two or more operators of the same precedence shall be left associative.”
(quote from ISO standards)
However, unlike some other programming languages, operator precedence ''does not'' define evaluation order.
This is because Pascal does not permit “lazy evaluation”:
▲<code> (a>n) and (b<n)</code>
Except in the case of <code>and_then</code> and <code>or_else</code>, the ''evaluation order implementation-defined''.
Some compilers, for instance the FPC ([[#Free Pascal|Free Pascal]] Compiler), evaluate “more complex” subexpression first before evaluating “easy” subexpressions (rationale: avoid register spilling).
=={{header|Perl}}==
|