Skip to content

Commit

Permalink
Minor syntax and formatting changes (ethereum#3337)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
celeduc authored and chriseth committed Dec 20, 2017
1 parent 8d0903e commit efc198d
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions docs/contracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ This means that cyclic creation dependencies are impossible.
{
// Create a new Token contract and return its address.
// 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.
return new OwnedToken(name);
}

function changeName(OwnedToken tokenAddress, bytes32 name) public {
// Again, the external type of "tokenAddress" is
// simply "address".
// Again, the external type of `tokenAddress` is
// simply `address`.
tokenAddress.changeName(name);
}

Expand Down Expand Up @@ -203,10 +203,10 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value
contract D {
function readData() public {
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);
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
}
}

Expand Down Expand Up @@ -308,9 +308,9 @@ inheritable properties of contracts and may be overridden by derived contracts.
address owner;

// 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
// "_;" in the definition of a modifier appears.
// `_;` in the definition of a modifier appears.
// This means that if the owner calls this function, the
// function is executed and otherwise, an exception is
// thrown.
Expand All @@ -321,9 +321,9 @@ inheritable properties of contracts and may be overridden by derived contracts.
}

contract mortal is owned {
// 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
// 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() public onlyOwner {
selfdestruct(owner);
Expand All @@ -346,7 +346,7 @@ inheritable properties of contracts and may be overridden by derived contracts.
function Register(uint initialPrice) public { price = initialPrice; }

// 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.
function register() public payable costs(price) {
registeredAddresses[msg.sender] = true;
Expand All @@ -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
/// 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
/// executes the statement `locked = false` in the modifier.
function f() public noReentrancy returns (uint) {
Expand Down Expand Up @@ -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:

#. Writing to state variables.
#. :ref:`Emitting events. <events>`.
#. :ref:`Emitting events <events>`.
#. :ref:`Creating other contracts <creating-contracts>`.
#. Using ``selfdestruct``.
#. Sending Ether via calls.
Expand Down Expand Up @@ -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 contract (there is no other function).
// 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.
function() public { x = 1; }
uint x;
Expand Down Expand Up @@ -744,7 +744,7 @@ The use in the JavaScript API would be as follows:
// watch for changes
event.watch(function(error, result){
// result will contain various information
// including the argumets given to the Deposit
// including the argumets given to the `Deposit`
// call.
if (!error)
console.log(result);
Expand Down Expand Up @@ -823,7 +823,7 @@ Details are given in the following example.
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
// internal functions and state variables. These cannot be
// accessed externally via `this`, though.
Expand All @@ -846,9 +846,9 @@ Details are given in the following example.
function unregister() public;
}

// Multiple inheritance is possible. Note that "owned" is
// also a base class of "mortal", yet there is only a single
// instance of "owned" (as for virtual inheritance in C++).
// Multiple inheritance is possible. Note that `owned` is
// also a base class of `mortal`, yet there is only a single
// instance of `owned` (as for virtual inheritance in C++).
contract named is owned, mortal {
function named(bytes32 name) {
Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970);
Expand Down Expand Up @@ -1133,7 +1133,7 @@ more advanced example to implement a set).
// reference" and thus only its storage address and not
// its contents is passed as part of the call. This is a
// 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.
function insert(Data storage self, uint value)
public
Expand Down Expand Up @@ -1177,7 +1177,7 @@ more advanced example to implement a set).
}

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
reference parameters, and they can have multiple storage reference
parameters and in any position.
Expand Down Expand Up @@ -1343,7 +1343,7 @@ Let us rewrite the set example from the
// Here, all variables of type Set.Data have
// corresponding member functions.
// The following function call is identical to
// Set.insert(knownValues, value)
// `Set.insert(knownValues, value)`
require(knownValues.insert(value));
}
}
Expand Down

0 comments on commit efc198d

Please sign in to comment.