Summary
purefor functions: Disallows modifition or access of state - this is not enforeced yet.viewfor functions: Disallow modifition of state - this is not enforced yet.payablefor functions: Allows them to receive Ether together with a call.constantfor state variables: Disallow assignment (except initialization), does not occupy storage slot.anonymousefor events: Does not store event signature as topic(indexable).indexedfor event parameters: Stores the parameter as topic(indexable).
Q: Solidity 0.4.16 introduced the
viewandconstantfunction modifiers. The documentation says:
constant for functions: Same as view
Does this mean
viewis just an alias forconstant?
Answer: This is discussed here
The keyword
viewis introduced for functions (it replaces constant). Calling a view cannot alter the behavior of future interaction with any contract. This means such functions cannot useSSTORE, cannotsendorreceiveether and can only call othervieworpurefunctions.The keyword
pureis introduced for functions, they are view functions with the additional restriction that their value only depends on the function arguments(pure function). This means they cannot useSSTORE,SLOAD, cannotsendorreceiveether, cannot usemsgorblockand can only call otherpurefunction.The keyword
constantis invalid on functionsThe keyword
constanton any variable means it cannot be modified (and could be placed into memory or bytecode by the optimiser)


