Skip to content
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 8 commits into from
Aug 1, 2016
Merged

Document precedence #732

merged 8 commits into from
Aug 1, 2016

Conversation

Denton-L
Copy link
Contributor

There is no documentation on the order of precedence of the various operators. This attempts to resolve this.

| *15* | Assignment operators | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, |
| | | ``/=``, ``%=`` |
+------------+-------------------------------------+--------------------------------------------+
| *16* | Comma operator | ``,`` |
Copy link
Contributor

@chriseth chriseth Jul 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no comma operator -- jedi mind trick

Copy link
Contributor Author

@Denton-L Denton-L Jul 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I'll change that. What's up with https://github.com/ethereum/solidity/blob/develop/libsolidity/parsing/Token.h#L107 though? Why does the comma have an order of precedence?

Copy link
Contributor

@chriseth chriseth Jul 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, ok, we have a comma token (as part of tuples, for example), but not on the level of statements, so you are right. it should stay, sorry for the confusion.

+------------+-------------------------------------+--------------------------------------------+
| *5* | Addition and subtraction | ``+``, ``-`` |
+------------+-------------------------------------+--------------------------------------------+
| *6* | Bitwise shift operators | ``<<``, ``>>``, ``>>>`` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove >>>, it is really not used.

@chriseth
Copy link
Contributor

Sorry for the confusion, please re-add the comma operator.

@Denton-L
Copy link
Contributor Author

Done. Can we remove >>> and >>>= from Token.h as well or do they serve some other purpose?

+ +-------------------------------------+--------------------------------------------+
| | Parentheses | ``(<statement>)`` |
+------------+-------------------------------------+--------------------------------------------+
| *2* | Prefix increment and decrement | ``++``, ``--`` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@Denton-L Denton-L Jul 27, 2016

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

Copy link
Contributor

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 now deadline will be current block timestamp + (2 * 7 * 24 * 60 * 60).

@axic
Copy link
Member

axic commented Jul 28, 2016

Done. Can we remove >>> and >>>= from Token.h as well or do they serve some other purpose?

More information is in #527.

@chriseth chriseth merged commit 6613346 into ethereum:develop Aug 1, 2016
@Denton-L Denton-L deleted the document-precedence branch August 2, 2016 15:51
@Sword-Smith
Copy link

Can you please specify the operator associativity also? Here:
https://solidity.readthedocs.io/en/v0.4.21/miscellaneous.html

@erak
Copy link
Collaborator

erak commented Oct 4, 2018

@Sword-Smith Could you please add an issue for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants