diff options
author | chriseth <chris@ethereum.org> | 2018-07-18 18:08:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-18 18:08:42 +0800 |
commit | b909df4573130e020c7f4dfb61c0571ba1bc02ab (patch) | |
tree | c5657726547d314fef6e80af702d061275afe5c7 /docs | |
parent | 1d33f41c1ab96746b97b97f79732ec23759fb8f0 (diff) | |
parent | 8b827af5bf4ed52c9612bcf1bdadb25ca7b879bf (diff) | |
download | dexon-solidity-b909df4573130e020c7f4dfb61c0571ba1bc02ab.tar.gz dexon-solidity-b909df4573130e020c7f4dfb61c0571ba1bc02ab.tar.zst dexon-solidity-b909df4573130e020c7f4dfb61c0571ba1bc02ab.zip |
Merge pull request #4430 from ethereum/enforceVisibilitySpecifier
[BREAKING] Enforce visibility specifier
Diffstat (limited to 'docs')
-rw-r--r-- | docs/contracts.rst | 15 | ||||
-rw-r--r-- | docs/control-structures.rst | 4 | ||||
-rw-r--r-- | docs/layout-of-source-files.rst | 2 | ||||
-rw-r--r-- | docs/types.rst | 3 |
4 files changed, 11 insertions, 13 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst index 033e9a45..51d7923d 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -131,10 +131,9 @@ a "message call") and external ones that do), there are four types of visibilities for functions and state variables. -Functions can be specified as being ``external``, -``public``, ``internal`` or ``private``, where the default is -``public``. For state variables, ``external`` is not possible -and the default is ``internal``. +Functions have to be specified as being ``external``, +``public``, ``internal`` or ``private``. +For state variables, ``external`` is not possible. ``external``: External functions are part of the contract @@ -850,10 +849,10 @@ Details are given in the following example. :: - pragma solidity ^0.4.22; + pragma solidity >0.4.24; contract owned { - constructor() { owner = msg.sender; } + constructor() public { owner = msg.sender; } address owner; } @@ -862,7 +861,7 @@ Details are given in the following example. // internal functions and state variables. These cannot be // accessed externally via `this`, though. contract mortal is owned { - function kill() { + function kill() public { if (msg.sender == owner) selfdestruct(owner); } } @@ -884,7 +883,7 @@ Details are given in the following example. // also a base class of `mortal`, yet there is only a single // instance of `owned` (as for virtual inheritance in C++). contract named is owned, mortal { - constructor(bytes32 name) { + constructor(bytes32 name) public { Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970); NameReg(config.lookup(1)).register(name); } diff --git a/docs/control-structures.rst b/docs/control-structures.rst index ead236c4..9fd017db 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -465,10 +465,10 @@ The following example shows how an error string can be used together with revert :: - pragma solidity ^0.4.22; + pragma solidity >0.4.24; contract VendingMachine { - function buy(uint amount) payable { + function buy(uint amount) public payable { if (amount > msg.value / 2 ether) revert("Not enough Ether provided."); // Alternative way to do it: diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index 81faf816..46ef3d57 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -205,7 +205,7 @@ for the two input parameters and two returned values. * @return s The calculated surface. * @return p The calculated perimeter. */ - function rectangle(uint w, uint h) returns (uint s, uint p) { + function rectangle(uint w, uint h) public returns (uint s, uint p) { s = w * h; p = 2 * (w + h); } diff --git a/docs/types.rst b/docs/types.rst index 0fe36757..c81dee33 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -483,7 +483,7 @@ Another example that uses external function types:: contract OracleUser { Oracle constant oracle = Oracle(0x1234567); // known contract - function buySomething() { + function buySomething() public { oracle.query("USD", this.oracleResponse); } function oracleResponse(bytes memory response) public { @@ -979,4 +979,3 @@ converted to a matching size. This makes alignment and padding explicit:: uint16 x = 0xffff; bytes32(uint256(x)); // pad on the left bytes32(bytes2(x)); // pad on the right - |