Minor syntax and formatting changes (#3337)

* Copyediting, mostly syntax.

* Use consistent quote chars inside sample code comments

* Revert to put back matching parenthesis

* Use single backticks for comment code quotes

wherever a reserved word, function or variable name is used in a comment
This commit is contained in:
Chuck LeDuc Díaz 2017-12-20 10:48:22 +01:00 committed by chriseth
parent 8d0903e26e
commit efc198d515

View File

@ -95,14 +95,14 @@ This means that cyclic creation dependencies are impossible.
{ {
// Create a new Token contract and return its address. // Create a new Token contract and return its address.
// From the JavaScript side, the return type is simply // From the JavaScript side, the return type is simply
// "address", as this is the closest type available in // `address`, as this is the closest type available in
// the ABI. // the ABI.
return new OwnedToken(name); return new OwnedToken(name);
} }
function changeName(OwnedToken tokenAddress, bytes32 name) public { function changeName(OwnedToken tokenAddress, bytes32 name) public {
// Again, the external type of "tokenAddress" is // Again, the external type of `tokenAddress` is
// simply "address". // simply `address`.
tokenAddress.changeName(name); tokenAddress.changeName(name);
} }
@ -203,10 +203,10 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value
contract D { contract D {
function readData() public { function readData() public {
C c = new C(); C c = new C();
uint local = c.f(7); // error: member "f" is not visible uint local = c.f(7); // error: member `f` is not visible
c.setData(3); c.setData(3);
local = c.getData(); local = c.getData();
local = c.compute(3, 5); // error: member "compute" is not visible local = c.compute(3, 5); // error: member `compute` is not visible
} }
} }
@ -308,9 +308,9 @@ inheritable properties of contracts and may be overridden by derived contracts.
address owner; address owner;
// This contract only defines a modifier but does not use // This contract only defines a modifier but does not use
// it - it will be used in derived contracts. // it: it will be used in derived contracts.
// The function body is inserted where the special symbol // The function body is inserted where the special symbol
// "_;" in the definition of a modifier appears. // `_;` in the definition of a modifier appears.
// 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.
@ -321,9 +321,9 @@ 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() public onlyOwner { function close() public onlyOwner {
selfdestruct(owner); selfdestruct(owner);
@ -346,7 +346,7 @@ inheritable properties of contracts and may be overridden by derived contracts.
function Register(uint initialPrice) public { price = initialPrice; } function Register(uint initialPrice) public { price = initialPrice; }
// It is important to also provide the // It is important to also provide the
// "payable" keyword here, otherwise the function will // `payable` keyword here, otherwise the function will
// automatically reject all Ether sent to it. // automatically reject all Ether sent to it.
function register() public payable costs(price) { function register() public payable costs(price) {
registeredAddresses[msg.sender] = true; registeredAddresses[msg.sender] = true;
@ -367,7 +367,7 @@ inheritable properties of contracts and may be overridden by derived contracts.
} }
/// This function is protected by a mutex, which means that /// This function is protected by a mutex, which means that
/// reentrant calls from within msg.sender.call cannot call f again. /// reentrant calls from within `msg.sender.call` cannot call `f` again.
/// The `return 7` statement assigns 7 to the return value but still /// The `return 7` statement assigns 7 to the return value but still
/// executes the statement `locked = false` in the modifier. /// executes the statement `locked = false` in the modifier.
function f() public noReentrancy returns (uint) { function f() public noReentrancy returns (uint) {
@ -448,7 +448,7 @@ Functions can be declared ``view`` in which case they promise not to modify the
The following statements are considered modifying the state: The following statements are considered modifying the state:
#. Writing to state variables. #. Writing to state variables.
#. :ref:`Emitting events. <events>`. #. :ref:`Emitting events <events>`.
#. :ref:`Creating other contracts <creating-contracts>`. #. :ref:`Creating other contracts <creating-contracts>`.
#. Using ``selfdestruct``. #. Using ``selfdestruct``.
#. Sending Ether via calls. #. Sending Ether via calls.
@ -561,7 +561,7 @@ Please ensure you test your fallback function thoroughly to ensure the execution
// This function is called for all messages sent to // This function is called for all messages sent to
// this contract (there is no other function). // this contract (there is no other function).
// Sending Ether to this contract will cause an exception, // Sending Ether to this contract will cause an exception,
// because the fallback function does not have the "payable" // because the fallback function does not have the `payable`
// modifier. // modifier.
function() public { x = 1; } function() public { x = 1; }
uint x; uint x;
@ -744,7 +744,7 @@ The use in the JavaScript API would be as follows:
// watch for changes // watch for changes
event.watch(function(error, result){ event.watch(function(error, result){
// result will contain various information // result will contain various information
// including the argumets given to the Deposit // including the argumets given to the `Deposit`
// call. // call.
if (!error) if (!error)
console.log(result); console.log(result);
@ -823,7 +823,7 @@ Details are given in the following example.
address owner; address owner;
} }
// Use "is" to derive from another contract. Derived // Use `is` to derive from another contract. Derived
// contracts can access all non-private members including // contracts can access all non-private members including
// internal functions and state variables. These cannot be // internal functions and state variables. These cannot be
// accessed externally via `this`, though. // accessed externally via `this`, though.
@ -846,9 +846,9 @@ Details are given in the following example.
function unregister() public; function unregister() public;
} }
// Multiple inheritance is possible. Note that "owned" is // Multiple inheritance is possible. Note that `owned` is
// also a base class of "mortal", yet there is only a single // also a base class of `mortal`, yet there is only a single
// instance of "owned" (as for virtual inheritance in C++). // instance of `owned` (as for virtual inheritance in C++).
contract named is owned, mortal { contract named is owned, mortal {
function named(bytes32 name) { function named(bytes32 name) {
Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970); Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970);
@ -1133,7 +1133,7 @@ more advanced example to implement a set).
// reference" and thus only its storage address and not // reference" and thus only its storage address and not
// its contents is passed as part of the call. This is a // its contents is passed as part of the call. This is a
// special feature of library functions. It is idiomatic // special feature of library functions. It is idiomatic
// to call the first parameter 'self', if the function can // to call the first parameter `self`, if the function can
// be seen as a method of that object. // be seen as a method of that object.
function insert(Data storage self, uint value) function insert(Data storage self, uint value)
public public
@ -1177,7 +1177,7 @@ more advanced example to implement a set).
} }
Of course, you do not have to follow this way to use Of course, you do not have to follow this way to use
libraries - they can also be used without defining struct libraries: they can also be used without defining struct
data types. Functions also work without any storage data types. Functions also work without any storage
reference parameters, and they can have multiple storage reference reference parameters, and they can have multiple storage reference
parameters and in any position. parameters and in any position.
@ -1343,7 +1343,7 @@ Let us rewrite the set example from the
// Here, all variables of type Set.Data have // Here, all variables of type Set.Data have
// corresponding member functions. // corresponding member functions.
// The following function call is identical to // The following function call is identical to
// Set.insert(knownValues, value) // `Set.insert(knownValues, value)`
require(knownValues.insert(value)); require(knownValues.insert(value));
} }
} }