Skip to content

Commit ee9e059

Browse files
authored
[spec/attribute] Improve static section (#3295)
1 parent 6d0e2e5 commit ee9e059

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

spec/attribute.dd

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,10 @@ $(H2 $(LNAME2 override, $(D override) Attribute))
586586

587587
$(H2 $(LNAME2 static, $(D static) Attribute))
588588

589-
$(P The $(D static) attribute applies to functions and data.
590-
It means that the declaration does not apply to a particular
589+
$(P The $(D static) attribute applies to functions and data.)
590+
591+
$(P Inside an aggregate type, a `static`
592+
declaration does not apply to a particular
591593
instance of an object, but to the type of the object. In
592594
other words, it means there is no $(D this) reference.
593595
$(D static) is ignored when applied to other declarations.
@@ -610,14 +612,21 @@ f.foobar(); // produces 7;
610612
---------------
611613

612614
$(P
613-
Static functions are never virtual.
615+
Static functions are never $(DDSUBLINK spec/function, virtual-functions, virtual).
614616
)
615617
$(P
616618
Static data has one instance per thread, not one per object.
617619
)
620+
$(P A static $(DDSUBLINK spec/function, nested, nested function) cannot
621+
access variables in the parent scope.)
622+
623+
$(P Inside a function, a $(DDSUBLINK spec/function, local-static-variables,
624+
static local variable) persists after the function returns.)
625+
618626
$(P
619627
Static does not have the additional C meaning of being local
620-
to a file. Use the $(D private) attribute in D to achieve that.
628+
to a file. Use the $(RELATIVE_LINK2 VisibilityAttribute, `private`)
629+
attribute in D to achieve that.
621630
For example:
622631
)
623632

0 commit comments

Comments
 (0)