Merge pull request #4022 from ethereum/docslin

Update documentation about C3 linearization.
This commit is contained in:
chriseth 2018-04-30 16:58:11 +02:00 committed by GitHub
commit 565b4a0f11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
======================================================