Section A1: Inform operators

Contents Back Forward | ### A1. Inform operators
| In the table, "Level'' refers to precedence level: thus `*`, on level 6, has precedence over `+`, down on level 5, but both subordinate to unary `-`, up on level 8. The "associativity'' of an operator is the way it brackets up if the formula doesn't specify this: for instance, `-` is left associative because
        a - b - c
is understood as
        (a - b) - c
with brackets going on the left. With some Inform operators, you're not allowed to be vague like this; these are the ones whose associative is listed as "none''. Thus
        a == b == c
will produce an error insisting that brackets be written into the program to make clear what the meaning is. Given the table (and sufficient patience) all expressions can be broken down into order: for instance
        a * b .& c --> d / - f
is calculated as
        ( a*((b.&c)-->d) ) / (-f)
0 | `,` | binary | left | separating values to work out
1 | `=` | binary | right | set equal to
2 | && | binary | left | logical AND
2 | || | binary | left | logical OR
2 | `~~` | unary | (pre) | logical NOT
3 | `==` | binary | none | equal to?
3 | `~=` | binary | none | not equal to?
3 | `>` | binary | none | greater than?
3 | `>=` | binary | none | greater than or equal to?
3 | `<` | binary | none | less than?
3 | `<=` | binary | none | less than or equal to?
3 | `has` | binary | none | object has this attribute?
3 | `hasnt` | binary | none | object hasn't this attribute?
3 | `in` | binary | none | first obj a child of second?
3 | `notin` | binary | none | first obj not a child of second?
3 | `ofclass` | binary | none | obj inherits from class?
3 | `provides` | binary | none | obj provides this property?
4 | `or` | binary | left | separating alternative values
5 | `+` | binary | left | 16-bit signed addition
5 | `-` | binary | left | 16-bit signed subtraction
6 | `*` | binary | left | 16-bit signed multiplication
6 | `/` | binary | left | 16-bit signed integer division
6 | `%` | binary | left | 16-bit signed remainder
6 | & | binary | left | bitwise AND
6 | | | binary | left | bitwise OR
6 | `~` | unary | (pre) | bitwise NOT
7 | `->` | binary | left | byte array entry
7 | `-->` | binary | left | word array entry
8 | `-` | unary | (pre) | 16-bit (signed!) negation
9 | `++` | unary | (pre/post) | increment
9 | `--` | unary | (pre/post) | decrement
10 | `.`& | binary | left | property address
10 | `.#` | binary | left | property length
11 | `(...)` | binary | left | function call on right hand side
12 | `.` | binary | left | property value
13 | `::` | binary | left | "superclass'' operator
14 | `(...)` | binary | left | function call on left hand side

Contents / Back / Forward
Chapter I / Chapter II / Chapter III / Chapter IV / Chapter V / Chapter VI / Appendix

Mechanically translated to HTML from third edition as revised 16 May 1997. Copyright © Graham Nelson 1993, 1994, 1995, 1996, 1997: all rights reserved.