You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clarify style guidance for contributors and package authors (#57577)
- Deduplicate style guide in CONTRIBUTING.md and manual/style-guide.md
- Link from CONTRIBUTING.md to the manual
- Clarify contradictory function naming guidance
I took out the "Underscores are also used to indicate a combination of
concepts" language because I don't think that accurately reflects when
base uses snake case.
Copy file name to clipboardExpand all lines: doc/src/manual/style-guide.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -172,17 +172,19 @@ Counter-examples to this rule include [`NamedTuple`](@ref), [`RegexMatch`](@ref
172
172
## Use naming conventions consistent with Julia `base/`
173
173
174
174
* modules and type names use capitalization and camel case: `module SparseArrays`, `struct UnitRange`.
175
-
* functions are lowercase ([`maximum`](@ref), [`convert`](@ref)) and, when readable, with multiple
176
-
words squashed together ([`isequal`](@ref), [`haskey`](@ref)). When necessary, use underscores
177
-
as word separators. Underscores are also used to indicate a combination of concepts ([`remotecall_fetch`](@ref)
178
-
as a more efficient implementation of `fetch(remotecall(...))`) or as modifiers.
175
+
* constants use all uppercase and underscores ([`LOAD_PATH`](@ref), [`VERSION`](@ref)).
176
+
* while anything not marked with `public` or `export` is considered internal, a prefix of
177
+
`_` also indicates that an object is not intended for public use.
179
178
* functions mutating at least one of their arguments end in `!`.
180
179
* conciseness is valued, but avoid abbreviation ([`indexin`](@ref) rather than `indxin`) as
181
180
it becomes difficult to remember whether and how particular words are abbreviated.
182
181
183
182
If a function name requires multiple words, consider whether it might represent more than one
184
183
concept and might be better split into pieces.
185
184
185
+
Function names should be written in snake case ([`minimum`](@ref), [`count_zeros`](@ref), [`escape_string`](@ref)).
186
+
Base often breaks this convention by squashing words together ([`splitpath`](@ref), [`readeach`](@ref)) but this style is not recommended for packages.
187
+
186
188
## Write functions with argument ordering similar to Julia Base
187
189
188
190
As a general rule, the Base library uses the following order of arguments to functions,
0 commit comments