authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-17 14:32:14-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-17 14:32:14-08:00
loge5dc5a6eb5608c100e78d6116942a4cd17f56d00
treee2121ba562cd163b8c5cabcbf3c6b19395c8a388
parent041701416be59b94189c3a9d85053e5d69e7ba2c

langref: refrain from underscore prefixes


1 files changed, 12 insertions(+), 0 deletions(-)

doc/langref.html.in+12
......@@ -7134,6 +7134,18 @@ coding style.
71347134 cannot be any more specific without being incorrect.</p>
71357135 {#header_close#}
71367136
7137 {#header_open|Refrain from Underscore Prefixes#}
7138 <p>In some programming languages, it is common to prefix identifiers with underscores
7139 {#syntax#}__like_this{#endsyntax#} to indicate some vague notion of privacy or danger
7140 associated with usage of the identifier.</p>
7141 <p>In Zig, there are no private fields, and it is better not to pretend
7142 otherwise. Fields should be named carefully to communicate their
7143 semantics and documentation should indicate how to use fields without
7144 violating data invariants. Underscore prefixes serve only to make code
7145 authors feel better about writing clumsy, overly prescriptive, poorly
7146 documented code.</p>
7147 {#header_close#}
7148
71377149 {#header_open|Whitespace#}
71387150 <ul>
71397151 <li>