[jit] Fix the saving of the 'cfg->ret_var_set' flag when inlining, it was set to...
[mono.git] / mcs / docs / ecma334 / 17.10.xml
1 <?xml version="1.0"?>
2 <clause number="17.10" title="Instance constructors">
3   <paragraph>An instance constructor is a member that implements the actions required to initialize an instance of a class. Instance constructors are declared using constructor-declarations: <grammar_production><name><non_terminal where="17.10">constructor-declaration</non_terminal></name> : <rhs><non_terminal where="24.2">attributes</non_terminal><opt/><non_terminal where="17.10">constructor-modifiers</non_terminal><opt/><non_terminal where="17.10">constructor-declarator</non_terminal><non_terminal where="17.10">constructor-body</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="17.10">constructor-modifier</non_terminal>s</name> : <rhs><non_terminal where="17.10">constructor-modifier</non_terminal></rhs><rhs><non_terminal where="17.10">constructor-modifiers</non_terminal><non_terminal where="17.10">constructor-modifier</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="17.10">constructor-modifier</non_terminal></name> : <rhs><keyword>public</keyword></rhs><rhs><keyword>protected</keyword></rhs><rhs><keyword>internal</keyword></rhs><rhs><keyword>private</keyword></rhs><rhs><keyword>extern</keyword></rhs></grammar_production><grammar_production><name><non_terminal where="17.10">constructor-declarator</non_terminal></name> : <rhs><non_terminal where="9.4.2">identifier</non_terminal><terminal>(</terminal><non_terminal where="17.5.1">formal-parameter-list</non_terminal><opt/><terminal>)</terminal><non_terminal where="17.10">constructor-initializer</non_terminal><opt/></rhs></grammar_production><grammar_production><name><non_terminal where="17.10">constructor-initializer</non_terminal></name> : <rhs><terminal>:</terminal><keyword>base</keyword><terminal>(</terminal><non_terminal where="14.4.1">argument-list</non_terminal><opt/><terminal>)</terminal></rhs><rhs><terminal>:</terminal><keyword>this</keyword><terminal>(</terminal><non_terminal where="14.4.1">argument-list</non_terminal><opt/><terminal>)</terminal></rhs></grammar_production><grammar_production><name><non_terminal where="17.10">constructor-body</non_terminal></name> : <rhs><non_terminal where="15.2">block</non_terminal></rhs><rhs><terminal>;</terminal></rhs></grammar_production></paragraph>
4   <paragraph>A <non_terminal where="17.10">constructor-declaration</non_terminal> may include a set of attributes (<hyperlink>24</hyperlink>), a valid combination of the four access modifiers (<hyperlink>17.2.3</hyperlink>), and an extern (<hyperlink>17.5.7</hyperlink>) modifier. A constructor declaration is not permitted to include the same modifier multiple times. </paragraph>
5   <paragraph>The identifier of a <non_terminal where="17.10">constructor-declarator</non_terminal> must name the class in which the instance constructor is declared. If any other name is specified, a compile-time error occurs. </paragraph>
6   <paragraph>The optional <non_terminal where="17.5.1">formal-parameter-list</non_terminal> of an instance constructor is subject to the same rules as the  <non_terminal where="17.5.1">formal-parameter-list</non_terminal> of a method (<hyperlink>17.5</hyperlink>). The formal parameter list defines the signature (<hyperlink>10.6</hyperlink>) of an instance constructor and governs the process whereby overload resolution (<hyperlink>14.4.2</hyperlink>) selects a particular instance constructor in an invocation. </paragraph>
7   <paragraph>Each of the types referenced in the <non_terminal where="17.5.1">formal-parameter-list</non_terminal> of an instance constructor must be at least as accessible as the constructor itself (<hyperlink>10.5.4</hyperlink>). </paragraph>
8   <paragraph>The optional <non_terminal where="17.10">constructor-initializer</non_terminal> specifies another instance constructor to invoke before executing the statements given in the <non_terminal where="17.10">constructor-body</non_terminal> of this instance constructor. This is described further in <hyperlink>17.10.1</hyperlink>. </paragraph>
9   <paragraph>When a constructor declaration includes an extern modifier, the constructor is said to be an external constructor. </paragraph>
10   <paragraph>Because an external constructor declaration provides no actual implementation, its <non_terminal where="17.10">constructor-body</non_terminal> consists of a semicolon. For all other constructors, the <non_terminal where="17.10">constructor-body</non_terminal> consists of a block, which specifies the statements to initialize a new instance of the class. This corresponds exactly to the block of an instance method with a <keyword>void</keyword> return type (<hyperlink>17.5.8</hyperlink>). </paragraph>
11   <paragraph>Instance constructors are not inherited. Thus, a class has no instance constructors other than those actually declared in the class. If a class contains no instance constructor declarations, a default instance constructor is automatically provided (<hyperlink>17.10.4</hyperlink>). </paragraph>
12   <paragraph>Instance constructors are invoked by <non_terminal where="14.5.10.1">object-creation-expression</non_terminal>s (<hyperlink>14.5.10.1</hyperlink>) and through  <non_terminal where="17.10">constructor-initializer</non_terminal>s. </paragraph>
13 </clause>