Skip to content

Commit 7b655f6

Browse files
committed
Straw man to address extern constructor requirements
Towards #1253 and #158.
1 parent ba031e9 commit 7b655f6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

standard/classes.md

+4
Original file line numberDiff line numberDiff line change
@@ -4896,6 +4896,8 @@ An instance constructor initializer cannot access the instance being created. Th
48964896
48974897
When an instance constructor has no constructor initializer, or it has a constructor initializer of the form `base(...)`, that constructor implicitly performs the initializations specified by the *variable_initializer*s of the instance fields declared in its class. This corresponds to a sequence of assignments that are executed immediately upon entry to the constructor and before the implicit invocation of the direct base class constructor. The variable initializers are executed in the textual order in which they appear in the class declaration ([§15.5.6](classes.md#1556-variable-initializers)).
48984898
4899+
Variable initializers are not required to be executed by extern instance constructors.
4900+
48994901
### 15.11.4 Constructor execution
49004902
49014903
Variable initializers are transformed into assignment statements, and these assignment statements are executed *before* the invocation of the base class instance constructor. This ordering ensures that all instance fields are initialized by their variable initializers before *any* statements that have access to that instance are executed.
@@ -5117,6 +5119,8 @@ If a class contains the `Main` method ([§7.1](basic-concepts.md#71-application-
51175119

51185120
To initialize a new closed class type, first a new set of static fields ([§15.5.2](classes.md#1552-static-and-instance-fields)) for that particular closed type is created. Each of the static fields is initialized to its default value ([§15.5.5](classes.md#1555-field-initialization)). Next, the static field initializers ([§15.5.6.2](classes.md#15562-static-field-initialization)) are executed for those static fields. Finally, the static constructor is executed.
51195121

5122+
The requirement for the static constructor to be executed *after* the static field initializers does not apply to external static constructors.
5123+
51205124
> *Example*: The example
51215125
>
51225126
> <!-- Example: {template:"standalone-console", name:"StaticConstructors1", inferOutput:true} -->

0 commit comments

Comments
 (0)