mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #732 from Denton-L/document-precedence
Document precedence
This commit is contained in:
commit
66133469e9
@ -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
|
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
|
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
|
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
|
.. index:: ! assignment
|
||||||
|
|
||||||
|
@ -202,6 +202,69 @@ Tips and Tricks
|
|||||||
Cheatsheet
|
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
|
.. 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
|
Global Variables
|
||||||
|
@ -12,6 +12,9 @@ see :ref:`type-deduction` below) at
|
|||||||
compile-time. Solidity provides several elementary types which can be combined
|
compile-time. Solidity provides several elementary types which can be combined
|
||||||
to form complex types.
|
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
|
.. index:: ! value type, ! type;value
|
||||||
|
|
||||||
Value Types
|
Value Types
|
||||||
|
Loading…
Reference in New Issue
Block a user