Skip to content

Commit 70d212d

Browse files
authored
[spec/enum] Tweak docs (#3656)
Move EnumMember above EnumMemberAttributes, as it is mentioned first. Split anonymous enums into separate grammar block. Add subheading for single member syntax. Explain that all enum members are manifest constants. Fix Issue 23571 - Discussion of manifest constants in enum documentation is confusing at best.
1 parent eed5f08 commit 70d212d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

spec/enum.dd

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ $(GNAME EnumMembers):
2222
$(GLINK EnumMember) $(D ,)
2323
$(GLINK EnumMember) $(D ,) $(GSELF EnumMembers)
2424

25+
$(GNAME EnumMember):
26+
$(GLINK EnumMemberAttributes)$(OPT) $(GLINK_LEX Identifier)
27+
$(GLINK EnumMemberAttributes)$(OPT) $(GLINK_LEX Identifier) $(D =) $(ASSIGNEXPRESSION)
28+
2529
$(GNAME EnumMemberAttributes):
2630
$(GLINK EnumMemberAttribute)
2731
$(GLINK EnumMemberAttribute) $(GSELF EnumMemberAttributes)
@@ -30,11 +34,8 @@ $(GNAME EnumMemberAttribute):
3034
$(GLINK2 attribute, DeprecatedAttribute)
3135
$(GLINK2 attribute, UserDefinedAttribute)
3236
$(D @)$(LINK2 attribute.html#disable, $(D disable))
33-
34-
$(GNAME EnumMember):
35-
$(GLINK EnumMemberAttributes)$(OPT) $(GLINK_LEX Identifier)
36-
$(GLINK EnumMemberAttributes)$(OPT) $(GLINK_LEX Identifier) $(D =) $(ASSIGNEXPRESSION)
37-
37+
)
38+
$(GRAMMAR
3839
$(GNAME AnonymousEnumDeclaration):
3940
$(D enum) $(D :) $(GLINK EnumBaseType) $(D {) $(GLINK EnumMembers) $(D })
4041
$(D enum) $(D {) $(GLINK AnonymousEnumMembers) $(D })
@@ -249,7 +250,7 @@ enum
249250
}
250251
---
251252

252-
$(H2 $(LNAME2 manifest_constants, Manifest Constants))
253+
$(H3 $(LNAME2 single_member, Single Member Syntax))
253254

254255
$(P If there is only one member of an anonymous enum, the `{ }` can
255256
be omitted. Gramatically speaking, this is an $(GLINK2 declaration, AutoDeclaration).
@@ -260,6 +261,10 @@ enum i = 4; // i is 4 of type int
260261
enum long l = 3; // l is 3 of type long
261262
---
262263

264+
$(H2 $(LNAME2 manifest_constants, Manifest Constants))
265+
266+
$(P Enum members are manifest constants, which exist only at compile-time.)
267+
263268
$(P Manifest constants are not lvalues, meaning their address
264269
cannot be taken. They exist only in the memory of the compiler.)
265270

0 commit comments

Comments
 (0)