Skip to content

Require 0.4.16 for view/pure in docs examples#2792

Merged
chriseth merged 3 commits intodevelopfrom
statemutability-docs
Aug 25, 2017
Merged

Require 0.4.16 for view/pure in docs examples#2792
chriseth merged 3 commits intodevelopfrom
statemutability-docs

Conversation

@axic
Copy link
Contributor

@axic axic commented Aug 24, 2017

Depends on #2745. To be merged after the release.

@chriseth
Copy link
Contributor

Can you take a look at gitter, please? Thanks!

@axic axic force-pushed the statemutability-docs branch 2 times, most recently from 474e311 to d4d967d Compare August 25, 2017 10:13
@axic axic requested a review from chriseth August 25, 2017 10:13
#. Writing to state variables.
#. :ref:`Creating other contracts <creating-contracts>`
#. Sending Ether via calls.
#. Using ``selfdestruct``.
Copy link
Contributor

Choose a reason for hiding this comment

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

Writing logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Emitting events".

#. :ref:`Creating other contracts <creating-contracts>`
#. Sending Ether via calls.
#. Using ``selfdestruct``.

Copy link
Contributor

Choose a reason for hiding this comment

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

Calling functions that are not marked view or pure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using low-level calls.
Using inline assembly that contains certain opcodes?

Copy link
Contributor

@chriseth chriseth Aug 25, 2017

Choose a reason for hiding this comment

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

Actually, do we want to mark modifiers as view and pure, or do we just infer that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calling functions was a remark below the list, but moved it into.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a separate issue (#1402) about having view/pure modifiers, I assume at this point we infer it.


Functions can be declared ``view`` in which case they promise not to modify the state.

The following statements are modifying the state:
Copy link
Contributor

Choose a reason for hiding this comment

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

... are considered modifying ....


In addition to the list of state modifying statements explained above, the following are reading from the state:
#. Reading from state variables.
#. :ref:`Emitting events. <events>`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why should that read?

#. Reading from state variables.
#. :ref:`Emitting events. <events>`
#. Accessing ``this.balance`` or ``<address>.balance``
#. Accessing any of the members of ``tx``, ``msg`` or ``block``.
Copy link
Contributor

Choose a reason for hiding this comment

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

Apart from msg.sender, msg.data and msg.value. Actually all msg members should be fine, shouldn't they?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah,gas is not.

Copy link
Contributor Author

@axic axic Aug 25, 2017

Choose a reason for hiding this comment

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

I guess only msg.sig and msg.data is safe.

@axic axic force-pushed the statemutability-docs branch from d4d967d to f5ad39b Compare August 25, 2017 11:42
@axic
Copy link
Contributor Author

axic commented Aug 25, 2017

@chriseth updated, please review.

#. :ref:`Emitting events. <events>`
#. :ref:`Creating other contracts <creating-contracts>`
#. Using ``selfdestruct``.
#. Sending Ether via calls.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is redundant as a function cannot be marked view/pure and payable, but I guess it cannot hurt atm (since it is not enforced).

@axic axic force-pushed the statemutability-docs branch 3 times, most recently from 26ce843 to ef3817f Compare August 25, 2017 11:47
@axic axic force-pushed the statemutability-docs branch from ef3817f to 2af949b Compare August 25, 2017 11:50
@chriseth chriseth merged commit 1417e5a into develop Aug 25, 2017
@axic axic deleted the statemutability-docs branch August 25, 2017 12:23
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.

2 participants