mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #13741 from ethereum/consistent-bound-function-terminology
Consistent terminology for attached/bound functions
This commit is contained in:
@@ -16,23 +16,24 @@ at contract level.
|
||||
|
||||
The first part, ``A``, can be one of:
|
||||
|
||||
- a list of file-level or library functions (``using {f, g, h, L.t} for uint;``) -
|
||||
only those functions will be attached to the type.
|
||||
- the name of a library (``using L for uint;``) -
|
||||
all functions (both public and internal ones) of the library are attached to the type
|
||||
- A list of file-level or library functions (e.g. ``using {f, g, h, L.t} for uint;``) -
|
||||
only those functions will be attached to the type as member functions.
|
||||
Note that private library functions can only be specified when ``using for`` is inside the library.
|
||||
- The name of a library (e.g. ``using L for uint;``) -
|
||||
all non-private functions of the library are attached to the type.
|
||||
|
||||
At file level, the second part, ``B``, has to be an explicit type (without data location specifier).
|
||||
Inside contracts, you can also use ``using L for *;``,
|
||||
Inside contracts, you can also use ``*`` in place of the type (e.g. ``using L for *;``),
|
||||
which has the effect that all functions of the library ``L``
|
||||
are attached to *all* types.
|
||||
|
||||
If you specify a library, *all* functions in the library are attached,
|
||||
If you specify a library, *all* functions in the library get 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.
|
||||
|
||||
If you use a list of functions (``using {f, g, h, L.t} for uint;``),
|
||||
If you use a list of functions (e.g. ``using {f, g, h, L.t} for uint;``),
|
||||
then the type (``uint``) has to be implicitly convertible to the
|
||||
first parameter of each of these functions. This check is
|
||||
performed even if none of these functions are called.
|
||||
|
||||
@@ -312,7 +312,7 @@ errorDefinition:
|
||||
Semicolon;
|
||||
|
||||
/**
|
||||
* Using directive to bind library functions and free functions to types.
|
||||
* Using directive to attach library functions and free functions to types.
|
||||
* Can occur within contracts and libraries and at the file level.
|
||||
*/
|
||||
usingDirective: Using (identifierPath | (LBrace identifierPath (Comma identifierPath)* RBrace)) For (Mul | typeName) Global? Semicolon;
|
||||
|
||||
@@ -664,7 +664,7 @@ introduced type and ``V`` has to be a built-in value type (the "underlying type"
|
||||
``C.wrap`` is used to convert from the underlying type to the custom type. Similarly, the
|
||||
function ``C.unwrap`` is used to convert from the custom type to the underlying type.
|
||||
|
||||
The type ``C`` does not have any operators or bound member functions. In particular, even the
|
||||
The type ``C`` does not have any operators or attached member functions. In particular, even the
|
||||
operator ``==`` is not defined. Explicit and implicit conversions to and from other types are
|
||||
disallowed.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user