diff options
author | chriseth <chris@ethereum.org> | 2018-07-04 20:16:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-04 20:16:46 +0800 |
commit | 7101a8905656d52cf9023a2e4340219d184920c3 (patch) | |
tree | dcb667aa61dedd1a9c913c0987a429da92421ad3 /docs/style-guide.rst | |
parent | 4a332ab324ae1badafb43a5844863ccd98e85c63 (diff) | |
parent | 8fdf3f5d456578d911b005cd52b8ee1fe34317b7 (diff) | |
download | dexon-solidity-7101a8905656d52cf9023a2e4340219d184920c3.tar.gz dexon-solidity-7101a8905656d52cf9023a2e4340219d184920c3.tar.zst dexon-solidity-7101a8905656d52cf9023a2e4340219d184920c3.zip |
Merge pull request #4380 from elopio/patch-3
Update examples to use constructor keyword
Diffstat (limited to 'docs/style-guide.rst')
-rw-r--r-- | docs/style-guide.rst | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 792110e1..8311e925 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -114,15 +114,15 @@ No:: .. _maximum_line_length: -Maximum Line Length +Maximum Line Length =================== -Keeping lines under the `PEP 8 recommendation <https://www.python.org/dev/peps/pep-0008/#maximum-line-length>`_ to a maximum of 79 (or 99) +Keeping lines under the `PEP 8 recommendation <https://www.python.org/dev/peps/pep-0008/#maximum-line-length>`_ to a maximum of 79 (or 99) characters helps readers easily parse the code. Wrapped lines should conform to the following guidelines. -1. The first argument should not be attached to the opening parenthesis. +1. The first argument should not be attached to the opening parenthesis. 2. One, and only one, indent should be used. 3. Each argument should fall on its own line. 4. The terminating element, :code:`);`, should be placed on the final line by itself. @@ -132,38 +132,38 @@ Function Calls Yes:: thisFunctionCallIsReallyLong( - longArgument1, - longArgument2, + longArgument1, + longArgument2, longArgument3 ); No:: - thisFunctionCallIsReallyLong(longArgument1, - longArgument2, + thisFunctionCallIsReallyLong(longArgument1, + longArgument2, longArgument3 ); - - thisFunctionCallIsReallyLong(longArgument1, - longArgument2, + + thisFunctionCallIsReallyLong(longArgument1, + longArgument2, longArgument3 - ); - + ); + thisFunctionCallIsReallyLong( longArgument1, longArgument2, longArgument3 - ); + ); thisFunctionCallIsReallyLong( - longArgument1, - longArgument2, + longArgument1, + longArgument2, longArgument3 ); thisFunctionCallIsReallyLong( - longArgument1, - longArgument2, - longArgument3); + longArgument1, + longArgument2, + longArgument3); Assignment Statements @@ -215,7 +215,7 @@ No:: recipient, publicKey, amount, - options); + options); Source File Encoding ==================== @@ -274,7 +274,7 @@ Within a grouping, place the ``view`` and ``pure`` functions last. Yes:: contract A { - function A() public { + constructor() public { ... } @@ -318,7 +318,7 @@ No:: // Public functions // ... - function A() public { + constructor() public { ... } @@ -529,7 +529,7 @@ No:: function increment(uint x) public pure returns (uint) { return x + 1;} -You should explicitly label the visibility of all functions, including constructors. +You should explicitly label the visibility of all functions, including constructors. Yes:: @@ -540,7 +540,7 @@ Yes:: No:: function implicitlyPublic(uint val) { - doSomething(); + doSomething(); } The visibility modifier for a function should come before any custom @@ -663,19 +663,19 @@ Yes:: address a, address b, address c - ) - public + ) + public returns ( - address someAddressName, - uint256 LongArgument, + address someAddressName, + uint256 LongArgument, uint256 Argument ) - { + { doSomething() - + return ( - veryLongReturnArg1, - veryLongReturnArg2, + veryLongReturnArg1, + veryLongReturnArg2, veryLongReturnArg3 ); } @@ -686,16 +686,16 @@ No:: address a, address b, address c - ) - public - returns (address someAddressName, - uint256 LongArgument, + ) + public + returns (address someAddressName, + uint256 LongArgument, uint256 Argument) - { + { doSomething() - - return (veryLongReturnArg1, - veryLongReturnArg1, + + return (veryLongReturnArg1, + veryLongReturnArg1, veryLongReturnArg1); } @@ -706,7 +706,7 @@ manner as modifiers if the function declaration is long or hard to read. Yes:: contract A is B, C, D { - function A(uint param1, uint param2, uint param3, uint param4, uint param5) + constructor(uint param1, uint param2, uint param3, uint param4, uint param5) B(param1) C(param2, param3) D(param4) @@ -719,7 +719,7 @@ Yes:: No:: contract A is B, C, D { - function A(uint param1, uint param2, uint param3, uint param4, uint param5) + constructor(uint param1, uint param2, uint param3, uint param4, uint param5) B(param1) C(param2, param3) D(param4) @@ -730,7 +730,7 @@ No:: } contract A is B, C, D { - function A(uint param1, uint param2, uint param3, uint param4, uint param5) + constructor(uint param1, uint param2, uint param3, uint param4, uint param5) B(param1) C(param2, param3) D(param4) |