diff options
author | chriseth <c@ethdev.com> | 2016-05-19 07:40:15 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-05-19 07:40:15 +0800 |
commit | cb865fb2b1be9d31b40bbd547c603c2bb81283b1 (patch) | |
tree | c6d815bd4448c335536d5f8b5a0bd9e5f80ea048 /docs | |
parent | 8efd6dd27a9ae1ccb8391ac326f04dff55129b5f (diff) | |
parent | 8bd111525560f3819597cfc77f60dc025c3c19eb (diff) | |
download | dexon-solidity-cb865fb2b1be9d31b40bbd547c603c2bb81283b1.tar dexon-solidity-cb865fb2b1be9d31b40bbd547c603c2bb81283b1.tar.gz dexon-solidity-cb865fb2b1be9d31b40bbd547c603c2bb81283b1.tar.bz2 dexon-solidity-cb865fb2b1be9d31b40bbd547c603c2bb81283b1.tar.lz dexon-solidity-cb865fb2b1be9d31b40bbd547c603c2bb81283b1.tar.xz dexon-solidity-cb865fb2b1be9d31b40bbd547c603c2bb81283b1.tar.zst dexon-solidity-cb865fb2b1be9d31b40bbd547c603c2bb81283b1.zip |
Merge pull request #581 from Denton-L/docs-corrections
Minor Corrections to Documentation Content
Diffstat (limited to 'docs')
-rw-r--r-- | docs/contracts.rst | 27 | ||||
-rw-r--r-- | docs/control-structures.rst | 8 | ||||
-rw-r--r-- | docs/frequently-asked-questions.rst | 8 | ||||
-rw-r--r-- | docs/miscellaneous.rst | 12 | ||||
-rw-r--r-- | docs/style-guide.rst | 22 | ||||
-rw-r--r-- | docs/units-and-global-variables.rst | 4 |
6 files changed, 42 insertions, 39 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst index dd75e857..1fd23732 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -185,7 +185,7 @@ return parameter list for functions. :: - contract c { + contract C { function f(uint a) private returns (uint b) { return a + 1; } function setData(uint a) internal { data = a; } uint public data; @@ -214,7 +214,7 @@ it is a state variable and if it is accessed externally :: - contract test { + contract Test { uint public data = 42; } @@ -222,7 +222,7 @@ The next example is a bit more complex: :: - contract complex { + contract Complex { struct Data { uint a; bytes3 b; @@ -266,7 +266,7 @@ inheritable properties of contracts and may be overridden by derived contracts. // This means that if the owner calls this function, the // function is executed and otherwise, an exception is // thrown. - modifier onlyowner { + modifier onlyOwner { if (msg.sender != owner) throw; _ @@ -275,11 +275,11 @@ inheritable properties of contracts and may be overridden by derived contracts. contract mortal is owned { - // This contract inherits the "onlyowner"-modifier from + // This contract inherits the "onlyOwner"-modifier from // "owned" and applies it to the "close"-function, which // causes that calls to "close" only have an effect if // they are made by the stored owner. - function close() onlyowner { + function close() onlyOwner { selfdestruct(owner); } } @@ -305,7 +305,7 @@ inheritable properties of contracts and may be overridden by derived contracts. registeredAddresses[msg.sender] = true; } - function changePrice(uint _price) onlyowner { + function changePrice(uint _price) onlyOwner { price = _price; } } @@ -717,13 +717,13 @@ Abstract Contracts Contract functions can lack an implementation as in the following example (note that the function declaration header is terminated by `;`):: - contract feline { + contract Feline { function utterance() returns (bytes32); } Such contracts cannot be compiled (even if they contain implemented functions alongside non-implemented functions), but they can be used as base contracts:: - contract Cat is feline { + contract Cat is Feline { function utterance() returns (bytes32) { return "miaow"; } } @@ -837,7 +837,7 @@ custom types without the overhead of external function calls: :: - library bigint { + library BigInt { struct bigint { uint[] limbs; } @@ -880,7 +880,8 @@ custom types without the overhead of external function calls: contract C { - using bigint for bigint.bigint; + using BigInt for BigInt.bigint; + function f() { var x = bigint.fromUint(7); var y = bigint.fromUint(uint(-1)); @@ -890,8 +891,8 @@ custom types without the overhead of external function calls: As the compiler cannot know where the library will be deployed at, these addresses have to be filled into the -final bytecode by a linker (see [Using the Commandline -Compiler](#using-the-commandline-compiler) on how to use the +final bytecode by a linker +(see :ref:`commandline-compiler`) on how to use the commandline compiler for linking). If the addresses are not given as arguments to the compiler, the compiled hex code will contain placeholders of the form `__Set______` (where diff --git a/docs/control-structures.rst b/docs/control-structures.rst index c26300a3..15effb78 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -31,7 +31,7 @@ Internal Function Calls Functions of the current contract can be called directly ("internally"), also recursively, as seen in this nonsensical example:: - contract c { + contract C { function g(uint a) returns (uint ret) { return f(); } function f() returns (uint ret) { return g(7) + f(); } } @@ -77,7 +77,7 @@ of unused parameters (especially return parameters) can be omitted. :: - contract c { + contract C { function f(uint key, uint value) { ... } function g() { @@ -541,7 +541,7 @@ It is planned that the stack height changes can be specified in inline assembly. .. code:: - contract c { + contract C { uint b; function f(uint x) returns (uint r) { assembly { @@ -615,7 +615,7 @@ be just `0`, but it can also be a complex functional-style expression. .. code:: - contract c { + contract C { function f(uint x) returns (uint b) { assembly { let v := add(x, 1) diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst index ff4d6fc0..a081fc16 100644 --- a/docs/frequently-asked-questions.rst +++ b/docs/frequently-asked-questions.rst @@ -2,7 +2,7 @@ Frequently Asked Questions ########################### -This list was originally compiled by [fivedogit](mailto:fivedogit@gmail.com). +This list was originally compiled by `fivedogit <mailto:fivedogit@gmail.com>`_. *************** @@ -179,7 +179,7 @@ Mappings are already syntactically similar to arrays as they are, therefore it d An example of this would be:: - contract c { + contract C { struct myStruct { uint someNumber; string someString; @@ -218,7 +218,7 @@ Example:: contract C { function f() returns (uint8[5]) { - string[4] memory AdaArr = ["This", "is", "an", "array"]; + string[4] memory adaArr = ["This", "is", "an", "array"]; return ([1, 2, 3, 4, 5]); } } @@ -360,7 +360,7 @@ Examples:: S public x = S(1, 2); string name = "Ada"; - string[4] memory AdaArr = ["This", "is", "an", "array"]; + string[4] memory adaArr = ["This", "is", "an", "array"]; } diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 19fbe85c..4a7b8438 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -31,10 +31,10 @@ non-elementary type, the positions are found by adding an offset of `sha3(k . p) So for the following contract snippet:: - contract c { - struct S { uint a; uint b; } + contract C { + struct s { uint a; uint b; } uint x; - mapping(uint => mapping(uint => S)) data; + mapping(uint => mapping(uint => s)) data; } The position of `data[4][9].b` is at `sha3(uint256(9) . sha3(uint256(4) . uint256(1))) + 1`. @@ -97,6 +97,8 @@ even though the instructions contained a jump in the beginning. .. index:: ! commandline compiler, compiler;commandline, ! solc, ! linker +.. _commandline-compiler: + ****************************** Using the Commandline Compiler ****************************** @@ -119,7 +121,7 @@ files reside, so things like `import "/etc/passwd";` only work if you add `=/` a If there are multiple matches due to remappings, the one with the longest common prefix is selected. -If your contracts use [libraries](#libraries), you will notice that the bytecode contains substrings of the form `__LibraryName______`. You can use `solc` as a linker meaning that it will insert the library addresses for you at those points: +If your contracts use :ref:`libraries <libraries>`, you will notice that the bytecode contains substrings of the form `__LibraryName______`. You can use `solc` as a linker meaning that it will insert the library addresses for you at those points: Either add `--libraries "Math:0x12345678901234567890 Heap:0xabcdef0123456"` to your command to provide an address for each library or store the string in a file (one library per line) and run `solc` using `--libraries fileName`. @@ -170,7 +172,7 @@ Global Variables - `sha3(...) returns (bytes32)`: compute the Ethereum-SHA3 hash of the (tightly packed) arguments - `sha256(...) returns (bytes32)`: compute the SHA256 hash of the (tightly packed) arguments - `ripemd160(...) returns (bytes20)`: compute RIPEMD of 256 the (tightly packed) arguments -- `ecrecover(bytes32, uint8, bytes32, bytes32) returns (address)`: recover public key from elliptic curve signature +- `ecrecover(bytes32, uint8, bytes32, bytes32) returns (address)`: recover address associated with the public key from elliptic curve signature - `addmod(uint x, uint y, uint k) returns (uint)`: compute `(x + y) % k` where the addition is performed with arbitrary precision and does not wrap around at `2**256`. - `mulmod(uint x, uint y, uint k) returns (uint)`: compute `(x * y) % k` where the multiplication is performed with arbitrary precision and does not wrap around at `2**256`. - `this` (current contract's type): the current contract, explicitly convertible to `address` diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 02f89bb8..332b1ba6 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -252,7 +252,7 @@ No:: for (...) { ...;} -For control structures who's body contains a single statement, omitting the +For control structures whose body contains a single statement, omitting the braces is ok *if* the statement is contained on a single line. Yes:: @@ -365,14 +365,14 @@ Yes:: address e, address f ) { - do_something; + doSomething(); } No:: function thisFunctionHasLotsOfArguments(address a, address b, address c, address d, address e, address f) { - do_something; + doSomething(); } function thisFunctionHasLotsOfArguments(address a, @@ -381,7 +381,7 @@ No:: address d, address e, address f) { - do_something; + doSomething(); } function thisFunctionHasLotsOfArguments( @@ -391,7 +391,7 @@ No:: address d, address e, address f) { - do_something; + doSomething(); } If a long function declaration has modifiers, then each modifier should be @@ -405,7 +405,7 @@ Yes:: priced returns (address) { - do_something; + doSomething(); } function thisFunctionNameIsReallyLong( @@ -418,7 +418,7 @@ Yes:: priced returns (address) { - do_something; + doSomething(); } No:: @@ -428,13 +428,13 @@ No:: onlyowner priced returns (address) { - do_something; + doSomething(); } function thisFunctionNameIsReallyLong(address x, address y, address z) public onlyowner priced returns (address) { - do_something; + doSomething(); } function thisFunctionNameIsReallyLong(address x, address y, address z) @@ -442,10 +442,10 @@ No:: onlyowner priced returns (address) { - do_something; + doSomething(); } -For constructor functions on inherited contracts who's bases require arguments, +For constructor functions on inherited contracts whose bases require arguments, it is recommended to drop the base constructors onto new lines in the same manner as modifiers if the function declaration is long or hard to read. diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index 9ddf52b1..f1560d25 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -94,8 +94,8 @@ Mathematical and Cryptographic Functions compute the SHA-256 hash of the (tightly packed) arguments `ripemd160(...) returns (bytes20)`: compute RIPEMD-160 hash of the (tightly packed) arguments -`ecrecover(bytes32, uint8, bytes32, bytes32) returns (address)`: - recover public key from elliptic curve signature - arguments are (data, v, r, s) +`ecrecover(bytes32 data, uint8 v, bytes32 r, bytes32 s) returns (address)`: + recover the address associated with the public key from elliptic curve signature In the above, "tightly packed" means that the arguments are concatenated without padding. This means that the following are all identical:: |