From 4259c0d036a503069de451ab701fe53b4a815150 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Sat, 5 May 2018 21:41:47 +0000 Subject: docs: document the implicit call of base constructor without arguments --- docs/contracts.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/contracts.rst b/docs/contracts.rst index 5c298274..add072a9 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -982,7 +982,7 @@ virtual method lookup. Constructors ============ -A constructor is an optional function declared with the ``constructor`` keyword which is executed upon contract creation. +A constructor is an optional function declared with the ``constructor`` keyword which is executed upon contract creation. Constructor functions can be either ``public`` or ``internal``. If there is no constructor, the contract will assume the default constructor: ``contructor() public {}``. @@ -1059,6 +1059,9 @@ derived contract. Arguments have to be given either in the inheritance list or in modifier-style in the derived constuctor. Specifying arguments in both places is an error. +If the constructor of a base contract has no arguments, it will be implicitly +executed upon contract creation. + .. index:: ! inheritance;multiple, ! linearization, ! C3 linearization Multiple Inheritance and Linearization @@ -1139,7 +1142,7 @@ Example of a Function Type (a variable declaration, where the variable is of typ function(address) external returns (address) foo; -Abstract contracts decouple the definition of a contract from its implementation providing better extensibility and self-documentation and +Abstract contracts decouple the definition of a contract from its implementation providing better extensibility and self-documentation and facilitating patterns like the `Template method `_ and removing code duplication. .. index:: ! contract;interface, ! interface contract -- cgit v1.2.3 From 114a0cf9539c9446461431834010cfde36fb8ac5 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Tue, 8 May 2018 17:26:37 +0000 Subject: document that all the base constructors are called --- docs/contracts.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/contracts.rst b/docs/contracts.rst index add072a9..9551fcc7 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -1030,8 +1030,9 @@ A constructor set as ``internal`` causes the contract to be marked as :ref:`abst Arguments for Base Constructors =============================== -Derived contracts need to provide all arguments needed for -the base constructors. This can be done in two ways:: +The constructors of all the base contracts will be called following the +linearization rules explained below. If the base constructors have arguments, +derived contracts need to specify all of them. This can be done in two ways:: pragma solidity ^0.4.22; @@ -1059,8 +1060,8 @@ derived contract. Arguments have to be given either in the inheritance list or in modifier-style in the derived constuctor. Specifying arguments in both places is an error. -If the constructor of a base contract has no arguments, it will be implicitly -executed upon contract creation. +If a derived contract doesn't specify the arguments to all of its base +contracts' constructors, it will be abstract. .. index:: ! inheritance;multiple, ! linearization, ! C3 linearization -- cgit v1.2.3