mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #581 from Denton-L/docs-corrections
Minor Corrections to Documentation Content
This commit is contained in:
		
						commit
						cb865fb2b1
					
				| @ -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 f(uint a) private returns (uint b) { return a + 1; } | ||||||
|         function setData(uint a) internal { data = a; } |         function setData(uint a) internal { data = a; } | ||||||
|         uint public data; |         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; |         uint public data = 42; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -222,7 +222,7 @@ The next example is a bit more complex: | |||||||
| 
 | 
 | ||||||
| :: | :: | ||||||
| 
 | 
 | ||||||
|     contract complex { |     contract Complex { | ||||||
|         struct Data { |         struct Data { | ||||||
|             uint a; |             uint a; | ||||||
|             bytes3 b; |             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 |         // This means that if the owner calls this function, the | ||||||
|         // function is executed and otherwise, an exception is |         // function is executed and otherwise, an exception is | ||||||
|         // thrown. |         // thrown. | ||||||
|         modifier onlyowner { |         modifier onlyOwner { | ||||||
|             if (msg.sender != owner) |             if (msg.sender != owner) | ||||||
|                 throw; |                 throw; | ||||||
|             _ |             _ | ||||||
| @ -275,11 +275,11 @@ inheritable properties of contracts and may be overridden by derived contracts. | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     contract mortal is owned { |     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 |         // "owned" and applies it to the "close"-function, which | ||||||
|         // causes that calls to "close" only have an effect if |         // causes that calls to "close" only have an effect if | ||||||
|         // they are made by the stored owner. |         // they are made by the stored owner. | ||||||
|         function close() onlyowner { |         function close() onlyOwner { | ||||||
|             selfdestruct(owner); |             selfdestruct(owner); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -305,7 +305,7 @@ inheritable properties of contracts and may be overridden by derived contracts. | |||||||
|             registeredAddresses[msg.sender] = true; |             registeredAddresses[msg.sender] = true; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         function changePrice(uint _price) onlyowner { |         function changePrice(uint _price) onlyOwner { | ||||||
|             price = _price; |             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 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); |         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:: | 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"; } |         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 { |         struct bigint { | ||||||
|             uint[] limbs; |             uint[] limbs; | ||||||
|         } |         } | ||||||
| @ -880,7 +880,8 @@ custom types without the overhead of external function calls: | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     contract C { |     contract C { | ||||||
|         using bigint for bigint.bigint; |         using BigInt for BigInt.bigint; | ||||||
|  | 
 | ||||||
|         function f() { |         function f() { | ||||||
|             var x = bigint.fromUint(7); |             var x = bigint.fromUint(7); | ||||||
|             var y = bigint.fromUint(uint(-1)); |             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 | As the compiler cannot know where the library will be | ||||||
| deployed at, these addresses have to be filled into the | deployed at, these addresses have to be filled into the | ||||||
| final bytecode by a linker (see [Using the Commandline | final bytecode by a linker | ||||||
| Compiler](#using-the-commandline-compiler) on how to use the | (see :ref:`commandline-compiler`) on how to use the | ||||||
| commandline compiler for linking). If the addresses are not | commandline compiler for linking). If the addresses are not | ||||||
| given as arguments to the compiler, the compiled hex code | given as arguments to the compiler, the compiled hex code | ||||||
| will contain placeholders of the form `__Set______` (where | will contain placeholders of the form `__Set______` (where | ||||||
|  | |||||||
| @ -31,7 +31,7 @@ Internal Function Calls | |||||||
| Functions of the current contract can be called directly ("internally"), also recursively, as seen in | Functions of the current contract can be called directly ("internally"), also recursively, as seen in | ||||||
| this nonsensical example:: | this nonsensical example:: | ||||||
| 
 | 
 | ||||||
|     contract c { |     contract C { | ||||||
|         function g(uint a) returns (uint ret) { return f(); } |         function g(uint a) returns (uint ret) { return f(); } | ||||||
|         function f() returns (uint ret) { return g(7) + 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 f(uint key, uint value) { ... } | ||||||
| 
 | 
 | ||||||
|         function g() { |         function g() { | ||||||
| @ -541,7 +541,7 @@ It is planned that the stack height changes can be specified in inline assembly. | |||||||
| 
 | 
 | ||||||
| .. code:: | .. code:: | ||||||
| 
 | 
 | ||||||
|     contract c { |     contract C { | ||||||
|         uint b; |         uint b; | ||||||
|         function f(uint x) returns (uint r) { |         function f(uint x) returns (uint r) { | ||||||
|             assembly { |             assembly { | ||||||
| @ -615,7 +615,7 @@ be just `0`, but it can also be a complex functional-style expression. | |||||||
| 
 | 
 | ||||||
| .. code:: | .. code:: | ||||||
| 
 | 
 | ||||||
|     contract c { |     contract C { | ||||||
|         function f(uint x) returns (uint b) { |         function f(uint x) returns (uint b) { | ||||||
|             assembly { |             assembly { | ||||||
|                 let v := add(x, 1) |                 let v := add(x, 1) | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| Frequently Asked Questions | 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:: | An example of this would be:: | ||||||
| 
 | 
 | ||||||
|     contract c { |     contract C { | ||||||
|         struct myStruct { |         struct myStruct { | ||||||
|             uint someNumber; |             uint someNumber; | ||||||
|             string someString; |             string someString; | ||||||
| @ -218,7 +218,7 @@ Example:: | |||||||
| 
 | 
 | ||||||
|     contract C { |     contract C { | ||||||
|         function f() returns (uint8[5]) { |         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]); |             return ([1, 2, 3, 4, 5]); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -360,7 +360,7 @@ Examples:: | |||||||
| 
 | 
 | ||||||
|         S public x = S(1, 2); |         S public x = S(1, 2); | ||||||
|         string name = "Ada"; |         string name = "Ada"; | ||||||
|         string[4] memory AdaArr = ["This", "is", "an", "array"]; |         string[4] memory adaArr = ["This", "is", "an", "array"]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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:: | So for the following contract snippet:: | ||||||
| 
 | 
 | ||||||
|     contract c { |     contract C { | ||||||
|       struct S { uint a; uint b; } |       struct s { uint a; uint b; } | ||||||
|       uint x; |       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`. | 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 | .. index:: ! commandline compiler, compiler;commandline, ! solc, ! linker | ||||||
| 
 | 
 | ||||||
|  | .. _commandline-compiler: | ||||||
|  | 
 | ||||||
| ****************************** | ****************************** | ||||||
| Using the 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 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`. | 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 | - `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 | - `sha256(...) returns (bytes32)`: compute the SHA256 hash of the (tightly packed) arguments | ||||||
| - `ripemd160(...) returns (bytes20)`: compute RIPEMD of 256 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`. | - `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`. | - `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` | - `this` (current contract's type): the current contract, explicitly convertible to `address` | ||||||
|  | |||||||
| @ -252,7 +252,7 @@ No:: | |||||||
|     for (...) { |     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. | braces is ok *if* the statement is contained on a single line. | ||||||
| 
 | 
 | ||||||
| Yes:: | Yes:: | ||||||
| @ -365,14 +365,14 @@ Yes:: | |||||||
|         address e, |         address e, | ||||||
|         address f |         address f | ||||||
|     ) { |     ) { | ||||||
|         do_something; |         doSomething(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| No:: | No:: | ||||||
| 
 | 
 | ||||||
|     function thisFunctionHasLotsOfArguments(address a, address b, address c, |     function thisFunctionHasLotsOfArguments(address a, address b, address c, | ||||||
|         address d, address e, address f) { |         address d, address e, address f) { | ||||||
|         do_something; |         doSomething(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function thisFunctionHasLotsOfArguments(address a, |     function thisFunctionHasLotsOfArguments(address a, | ||||||
| @ -381,7 +381,7 @@ No:: | |||||||
|                                             address d, |                                             address d, | ||||||
|                                             address e, |                                             address e, | ||||||
|                                             address f) { |                                             address f) { | ||||||
|         do_something; |         doSomething(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function thisFunctionHasLotsOfArguments( |     function thisFunctionHasLotsOfArguments( | ||||||
| @ -391,7 +391,7 @@ No:: | |||||||
|         address d, |         address d, | ||||||
|         address e, |         address e, | ||||||
|         address f) { |         address f) { | ||||||
|         do_something; |         doSomething(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| If a long function declaration has modifiers, then each modifier should be | If a long function declaration has modifiers, then each modifier should be | ||||||
| @ -405,7 +405,7 @@ Yes:: | |||||||
|         priced |         priced | ||||||
|         returns (address) |         returns (address) | ||||||
|     { |     { | ||||||
|         do_something; |         doSomething(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function thisFunctionNameIsReallyLong( |     function thisFunctionNameIsReallyLong( | ||||||
| @ -418,7 +418,7 @@ Yes:: | |||||||
|         priced |         priced | ||||||
|         returns (address) |         returns (address) | ||||||
|     { |     { | ||||||
|         do_something; |         doSomething(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| No:: | No:: | ||||||
| @ -428,13 +428,13 @@ No:: | |||||||
|                                           onlyowner |                                           onlyowner | ||||||
|                                           priced |                                           priced | ||||||
|                                           returns (address) { |                                           returns (address) { | ||||||
|         do_something; |         doSomething(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function thisFunctionNameIsReallyLong(address x, address y, address z) |     function thisFunctionNameIsReallyLong(address x, address y, address z) | ||||||
|         public onlyowner priced returns (address) |         public onlyowner priced returns (address) | ||||||
|     { |     { | ||||||
|         do_something; |         doSomething(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function thisFunctionNameIsReallyLong(address x, address y, address z) |     function thisFunctionNameIsReallyLong(address x, address y, address z) | ||||||
| @ -442,10 +442,10 @@ No:: | |||||||
|         onlyowner |         onlyowner | ||||||
|         priced |         priced | ||||||
|         returns (address) { |         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 | 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. | manner as modifiers if the function declaration is long or hard to read. | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -94,8 +94,8 @@ Mathematical and Cryptographic Functions | |||||||
|     compute the SHA-256 hash of the (tightly packed) arguments |     compute the SHA-256 hash of the (tightly packed) arguments | ||||||
| `ripemd160(...) returns (bytes20)`: | `ripemd160(...) returns (bytes20)`: | ||||||
|     compute RIPEMD-160 hash of the (tightly packed) arguments |     compute RIPEMD-160 hash of the (tightly packed) arguments | ||||||
| `ecrecover(bytes32, uint8, bytes32, bytes32) returns (address)`: | `ecrecover(bytes32 data, uint8 v, bytes32 r, bytes32 s) returns (address)`: | ||||||
|     recover public key from elliptic curve signature - arguments are (data, v, r, s) |     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. | In the above, "tightly packed" means that the arguments are concatenated without padding. | ||||||
| This means that the following are all identical:: | This means that the following are all identical:: | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user