Corrected spacing to four spaces

This commit is contained in:
Denton Liu 2016-05-11 15:53:45 -04:00
parent bdb48b8567
commit 14bd009eb6

View File

@ -32,8 +32,8 @@ Functions of the current contract can be called directly ("internally"), also re
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(); }
} }
These function calls are translated into simple jumps inside the EVM. This has These function calls are translated into simple jumps inside the EVM. This has
@ -53,12 +53,12 @@ When calling functions
of other contracts, the amount of Wei sent with the call and the gas can be specified:: of other contracts, the amount of Wei sent with the call and the gas can be specified::
contract InfoFeed { contract InfoFeed {
function info() returns (uint ret) { return 42; } function info() returns (uint ret) { return 42; }
} }
contract Consumer { contract Consumer {
InfoFeed feed; InfoFeed feed;
function setFeed(address addr) { feed = InfoFeed(addr); } function setFeed(address addr) { feed = InfoFeed(addr); }
function callFeed() { feed.info.value(10).gas(800)(); } function callFeed() { feed.info.value(10).gas(800)(); }
} }
Note that the expression `InfoFeed(addr)` performs an explicit type conversion stating Note that the expression `InfoFeed(addr)` performs an explicit type conversion stating
@ -76,15 +76,15 @@ 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() {
// named arguments // named arguments
f({value: 2, key: 3}); f({value: 2, key: 3});
} }
// omitted parameters // omitted parameters
function func(uint k, uint) returns(uint) { function func(uint k, uint) returns(uint) {
return k; return k;
} }
} }
Order of Evaluation of Expressions Order of Evaluation of Expressions
@ -109,29 +109,31 @@ Destructuring Assignments and Returning Multiple Values
Solidity internally allows tuple types, i.e. a list of objects of potentially different types whose size is a constant at compile-time. Those tuples can be used to return multiple values at the same time and also assign them to multiple variables (or LValues in general) at the same time:: Solidity internally allows tuple types, i.e. a list of objects of potentially different types whose size is a constant at compile-time. Those tuples can be used to return multiple values at the same time and also assign them to multiple variables (or LValues in general) at the same time::
contract C { contract C {
uint[] data; uint[] data;
function f() returns (uint, bool, uint) {
return (7, true, 2); function f() returns (uint, bool, uint) {
} return (7, true, 2);
function g() { }
// Declares and assigns the variables. Specifying the type explicitly is not possible.
var (x, b, y) = f(); function g() {
// Assigns to a pre-existing variable. // Declares and assigns the variables. Specifying the type explicitly is not possible.
(x, y) = (2, 7); var (x, b, y) = f();
// Common trick to swap values -- does not work for non-value storage types. // Assigns to a pre-existing variable.
(x, y) = (y, x); (x, y) = (2, 7);
// Components can be left out (also for variable declarations). // Common trick to swap values -- does not work for non-value storage types.
// If the tuple ends in an empty component, (x, y) = (y, x);
// the rest of the values are discarded. // Components can be left out (also for variable declarations).
(data.length,) = f(); // Sets the length to 7 // If the tuple ends in an empty component,
// The same can be done on the left side. // the rest of the values are discarded.
(,data[3]) = f(); // Sets data[3] to 2 (data.length,) = f(); // Sets the length to 7
// Components can only be left out at the left-hand-side of assignments, with // The same can be done on the left side.
// one exception: (,data[3]) = f(); // Sets data[3] to 2
(x,) = (1,); // Components can only be left out at the left-hand-side of assignments, with
// (1,) is the only way to specify a 1-component tuple, because (1) is // one exception:
// equivalent to 1. (x,) = (1,);
} // (1,) is the only way to specify a 1-component tuple, because (1) is
// equivalent to 1.
}
} }
Complications for Arrays and Structs Complications for Arrays and Structs