aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike <mikro2nd@users.noreply.github.com>2018-06-29 18:21:39 +0800
committerchriseth <chris@ethereum.org>2018-06-29 18:21:39 +0800
commit2a9d54af587c300d9dc5984a796200795302137d (patch)
treed0662a0eeda89880972fef5f9253d0c753ae00c9
parentc9cab803892a09386617faab6b4e1580ee2eaa47 (diff)
downloaddexon-solidity-2a9d54af587c300d9dc5984a796200795302137d.tar
dexon-solidity-2a9d54af587c300d9dc5984a796200795302137d.tar.gz
dexon-solidity-2a9d54af587c300d9dc5984a796200795302137d.tar.bz2
dexon-solidity-2a9d54af587c300d9dc5984a796200795302137d.tar.lz
dexon-solidity-2a9d54af587c300d9dc5984a796200795302137d.tar.xz
dexon-solidity-2a9d54af587c300d9dc5984a796200795302137d.tar.zst
dexon-solidity-2a9d54af587c300d9dc5984a796200795302137d.zip
Clarify scope of 'using A for B' (#4252)
* Issue 1213: Clarify scope of 'using A for B' * Typo fix. * Further restructuring and clarification of contracts doc. * Revert closer to original wording and formatting.
-rw-r--r--docs/contracts.rst23
1 files changed, 12 insertions, 11 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 5cfa7805..845fd973 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -1402,24 +1402,25 @@ Using For
*********
The directive ``using A for B;`` can be used to attach library
-functions (from the library ``A``) to any type (``B``).
+functions (from the library ``A``) to any type (``B``).
These functions will receive the object they are called on
-as their first parameter (like the ``self`` variable in
-Python).
+as their first parameter (like the ``self`` variable in Python).
The effect of ``using A for *;`` is that the functions from
-the library ``A`` are attached to any type.
+the library ``A`` are attached to *any* type.
-In both situations, all functions, even those where the
-type of the first parameter does not match the type of
-the object, are attached. The type is checked at the
+In both situations, *all* functions in the library are attached,
+even those where the type of the first parameter does not
+match the type of the object. The type is checked at the
point the function is called and function overload
resolution is performed.
-The ``using A for B;`` directive is active for the current
-scope, which is limited to a contract for now but will
-be lifted to the global scope later, so that by including
-a module, its data types including library functions are
+The ``using A for B;`` directive is active only within the current
+contract, including within all of its functions, and has no effect
+outside of the contract in which it is used. The directive
+may only be used inside a contract, not inside any of its functions.
+
+By including a library, its data types including library functions are
available without having to add further code.
Let us rewrite the set example from the