-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document precedence #732
Merged
Merged
Document precedence #732
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dfe55a9
Create order of precedence table
Denton-L 5d09211
Add link to operator table
Denton-L 1ec74f8
Remove comma operator
Denton-L ca5e6a6
Fix assignment operators
Denton-L 7143815
Revert "Remove comma operator"
Denton-L 8bf96b1
Remove >>> and >>>= operators
Denton-L 7a20324
Link to order of precedence table
Denton-L 5687beb
Add unary operations to the table
Denton-L File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,65 @@ 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 | ``+``, ``-`` | | ||
+ +-------------------------------------+--------------------------------------------+ | ||
| | Logical NOT | ``!`` | | ||
+ +-------------------------------------+--------------------------------------------+ | ||
| | Bitwise NOT | ``~`` | | ||
+------------+-------------------------------------+--------------------------------------------+ | ||
| *3* | Exponentiation | ``**`` | | ||
+------------+-------------------------------------+--------------------------------------------+ | ||
| *4* | Multiplication, division and modulo | ``*``, ``/``, ``%`` | | ||
+------------+-------------------------------------+--------------------------------------------+ | ||
| *5* | Addition and subtraction | ``+``, ``-`` | | ||
+------------+-------------------------------------+--------------------------------------------+ | ||
| *6* | Bitwise shift operators | ``<<``, ``>>``, ``>>>`` | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove |
||
+------------+-------------------------------------+--------------------------------------------+ | ||
| *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 | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove |
||
| | | ``>>=``, ``>>>=``, ``+=``, ``-=``, ``*=``, | | ||
| | | ``/=``, ``%=`` | | ||
+------------+-------------------------------------+--------------------------------------------+ | ||
|
||
.. 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 | ||
|
@@ -205,4 +264,3 @@ Modifiers | |
- ``constant`` for functions: Disallows modification of state - this is not enforced yet. | ||
- ``anonymous`` for events: Does not store event signature as topic. | ||
- ``indexed`` for event parameters: Stores the parameter as topic. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add
after
anddelete
https://github.com/ethereum/solidity/blob/d593166d66dba3f95df9d4096f45761ca0f86626/libsolidity/codegen/ExpressionCompiler.cpp#L300,L303
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, will do. Out of curiosity, what does the
after
keyword do?@NicolaiSoeborg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be used as
var deadline = after 2 weeks;
and nowdeadline
will becurrent block timestamp + (2 * 7 * 24 * 60 * 60)
.