Skip to content

Commit 5c8038d

Browse files
authored
Merge pull request #2076 from jacob-carlborg/style-guide-uda
Add naming convention about UDAs to the style guide
2 parents 4b1e83c + ff48fba commit 5c8038d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dstyle.dd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,22 @@ ubyte asciiChar;
135135
-------------------------------
136136
)
137137

138+
$(DT $(LNAME2 naming_udas, User-Defined Attributes))
139+
$(DD For symbols that are only to be used as user-defined attributes the
140+
names should be camelCased, so their first letter is lowercase. This
141+
convention takes precedence over any previously mentioned conventions.
142+
This matches conventions of the built in attributes like `@safe`,
143+
`@nogc` and the special compiler recognized UDA `@selector`.
138144

145+
-------------------------------
146+
struct Foo {} // this struct follows the regular naming conventions
147+
148+
// this struct is only intended to be used as an UDA and therefore overrides the
149+
// regular naming conventions for structs
150+
struct name { string value; }
151+
@name("bar") Foo foo;
152+
-------------------------------
153+
)
139154
)
140155

141156
$(H3 $(LNAME2 type_aliases, Type Aliases))

0 commit comments

Comments
 (0)