Skip to content

Commit 56b1cd0

Browse files
authored
Merge pull request #3778 from ntrel/class-static-this
[trivial] [spec/class] Tweak `static this` docs Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com> Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2 parents c5fac90 + f5ca0b9 commit 56b1cd0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

spec/class.dd

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,12 @@ $(GNAME StaticConstructor):
808808
$(P Static constructors are used to initialize static class members with
809809
values that cannot be computed at compile time.)
810810

811-
$(P Static constructors in other languages are built implicitly by using
811+
$(PANEL
812+
Static constructors in other languages are built implicitly by using
812813
member
813814
initializers that can't be computed at compile time. The trouble with
814815
this stems from not
815816
having good control over exactly when the code is executed, for example:
816-
)
817817

818818
------
819819
class Foo
@@ -823,9 +823,9 @@ class Foo
823823
}
824824
------
825825

826-
What values do a and b end up with, what order are the initializations
826+
What values do `a` and `b` end up with, what order are the initializations
827827
executed in, what
828-
are the values of a and b before the initializations are run, is this a
828+
are the values of `a` and `b` before the initializations are run, is this a
829829
compile error, or is this
830830
a runtime error? Additional confusion comes from it not being obvious if
831831
an initializer is
@@ -854,6 +854,7 @@ class Foo
854854
}
855855
}
856856
------
857+
)
857858

858859
$(P If $(D main()) or the thread returns normally, (does not throw an
859860
exception), the static destructor is added to the list of functions to be called
@@ -878,7 +879,7 @@ $(P Static constructors have empty parameter lists.)
878879
class Foo
879880
{
880881
static this() { ... } // a static constructor
881-
static private this() { ... } // not a static constructor
882+
static private this() { ... } // Error: not a static constructor
882883
static
883884
{
884885
this() { ... } // not a static constructor
@@ -925,7 +926,7 @@ class Foo
925926
class Foo
926927
{
927928
static ~this() { ... } // a static destructor
928-
static private ~this() { ... } // not a static destructor
929+
static private ~this() { ... } // Error: not a static destructor
929930
static
930931
{
931932
~this() { ... } // not a static destructor

0 commit comments

Comments
 (0)