mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update documentation about C3 linearization.
This commit is contained in:
parent
9e61b25dc4
commit
8782508e0b
@ -1066,12 +1066,15 @@ Multiple Inheritance and Linearization
|
||||
|
||||
Languages that allow multiple inheritance have to deal with
|
||||
several problems. One is the `Diamond Problem <https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem>`_.
|
||||
Solidity follows the path of Python and uses "`C3 Linearization <https://en.wikipedia.org/wiki/C3_linearization>`_"
|
||||
Solidity is similar to Python in that it uses "`C3 Linearization <https://en.wikipedia.org/wiki/C3_linearization>`_"
|
||||
to force a specific order in the DAG of base classes. This
|
||||
results in the desirable property of monotonicity but
|
||||
disallows some inheritance graphs. Especially, the order in
|
||||
which the base classes are given in the ``is`` directive is
|
||||
important. In the following code, Solidity will give the
|
||||
important: You have to list the direct base contracts
|
||||
in the order from "most base-like" to "most derived".
|
||||
Note that this order is different from the one used in Python.
|
||||
In the following code, Solidity will give the
|
||||
error "Linearization of inheritance graph impossible".
|
||||
|
||||
::
|
||||
@ -1089,9 +1092,6 @@ The reason for this is that ``C`` requests ``X`` to override ``A``
|
||||
requests to override ``X``, which is a contradiction that
|
||||
cannot be resolved.
|
||||
|
||||
A simple rule to remember is to specify the base classes in
|
||||
the order from "most base-like" to "most derived".
|
||||
|
||||
Inheriting Different Kinds of Members of the Same Name
|
||||
======================================================
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user