diff options
-rw-r--r-- | docs/control-structures.rst | 2 | ||||
-rw-r--r-- | docs/miscellaneous.rst | 63 | ||||
-rw-r--r-- | docs/types.rst | 3 |
3 files changed, 67 insertions, 1 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst index f30a5bdd..9d7ebeac 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -113,7 +113,7 @@ The evaluation order of expressions is not specified (more formally, the order in which the children of one node in the expression tree are evaluated is not specified, but they are of course evaluated before the node itself). It is only guaranteed that statements are executed in order and short-circuiting for -boolean expressions is done. +boolean expressions is done. See :ref:`order` for more information. .. index:: ! assignment diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 9b067fb1..76485745 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -202,6 +202,69 @@ Tips and Tricks Cheatsheet ********** +.. index:: precedence + +.. _order: + +Order of Precedence of Operators +================================ + +The following is the order of precedence for operators, listed in order of evaluation. + ++------------+-------------------------------------+--------------------------------------------+ +| Precedence | Description | Operator | ++============+=====================================+============================================+ +| *1* | Postfix increment and decrement | ``++``, ``--`` | ++ +-------------------------------------+--------------------------------------------+ +| | Function-like call | ``<func>(<args...>)`` | ++ +-------------------------------------+--------------------------------------------+ +| | Array subscripting | ``<array>[<index>]`` | ++ +-------------------------------------+--------------------------------------------+ +| | Member access | ``<object>.<member>`` | ++ +-------------------------------------+--------------------------------------------+ +| | Parentheses | ``(<statement>)`` | ++------------+-------------------------------------+--------------------------------------------+ +| *2* | Prefix increment and decrement | ``++``, ``--`` | ++ +-------------------------------------+--------------------------------------------+ +| | Unary plus and minus | ``+``, ``-`` | ++ +-------------------------------------+--------------------------------------------+ +| | Unary operations | ``after``, ``delete`` | ++ +-------------------------------------+--------------------------------------------+ +| | Logical NOT | ``!`` | ++ +-------------------------------------+--------------------------------------------+ +| | Bitwise NOT | ``~`` | ++------------+-------------------------------------+--------------------------------------------+ +| *3* | Exponentiation | ``**`` | ++------------+-------------------------------------+--------------------------------------------+ +| *4* | Multiplication, division and modulo | ``*``, ``/``, ``%`` | ++------------+-------------------------------------+--------------------------------------------+ +| *5* | Addition and subtraction | ``+``, ``-`` | ++------------+-------------------------------------+--------------------------------------------+ +| *6* | Bitwise shift operators | ``<<``, ``>>`` | ++------------+-------------------------------------+--------------------------------------------+ +| *7* | Bitwise AND | ``&`` | ++------------+-------------------------------------+--------------------------------------------+ +| *8* | Bitwise XOR | ``^`` | ++------------+-------------------------------------+--------------------------------------------+ +| *9* | Bitwise OR | ``|`` | ++------------+-------------------------------------+--------------------------------------------+ +| *10* | Inequality operators | ``<``, ``>``, ``<=``, ``>=`` | ++------------+-------------------------------------+--------------------------------------------+ +| *11* | Equality operators | ``==``, ``!=`` | ++------------+-------------------------------------+--------------------------------------------+ +| *12* | Logical AND | ``&&`` | ++------------+-------------------------------------+--------------------------------------------+ +| *13* | Logical OR | ``||`` | ++------------+-------------------------------------+--------------------------------------------+ +| *14* | Ternary operator | ``<conditional> ? <if-true> : <if-false>`` | ++------------+-------------------------------------+--------------------------------------------+ +| *15* | Assignment operators | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, | +| | | ``>>=``, ``+=``, ``-=``, ``*=``, ``/=``, | +| | | ``%=`` | ++------------+-------------------------------------+--------------------------------------------+ +| *16* | Comma operator | ``,`` | ++------------+-------------------------------------+--------------------------------------------+ + .. index:: block, coinbase, difficulty, number, block;number, timestamp, block;timestamp, msg, data, gas, sender, value, now, gas price, origin, sha3, ripemd160, sha256, ecrecover, addmod, mulmod, cryptography, this, super, selfdestruct, balance, send Global Variables diff --git a/docs/types.rst b/docs/types.rst index 50e86ed0..d7681ee5 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -12,6 +12,9 @@ see :ref:`type-deduction` below) at compile-time. Solidity provides several elementary types which can be combined to form complex types. +In addition, types can interact with each other in expressions containing +operators. For a quick reference of the various operators, see :ref:`order`. + .. index:: ! value type, ! type;value Value Types |