Updated Style Guide for Nim Code (markdown)
This commit is contained in:
parent
5b41dc79d4
commit
de24cfd0c2
|
@ -55,7 +55,7 @@ changed, there are many places in the standard library which still use this
|
|||
convention. Such style remains in place purely for legacy reasons, and will be
|
||||
changed in the future.
|
||||
|
||||
- Type identifiers should be in camelCase. All other identifiers should be in
|
||||
- Type identifiers should be in PascalCase. All other identifiers should be in
|
||||
camelCase with the exception of constants which **may** use PascalCase but
|
||||
are not required to.
|
||||
|
||||
|
@ -68,10 +68,14 @@ changed in the future.
|
|||
type FooBar = object
|
||||
```
|
||||
|
||||
For constants coming from a C/C++ wrapper, ALL_UPPERCASE are allowed, but ugly.
|
||||
(Why shout CONSTANT? Constants do no harm, variables do!)
|
||||
|
||||
- When naming types that come in value, pointer, and reference varieties, use a
|
||||
regular name for the variety that is to be used the most, and add a "Obj",
|
||||
"Ref", or "Ptr" suffix for the other varieties. If there is no single variety
|
||||
that will be used the most, add the suffixes to all versions.
|
||||
that will be used the most, add the suffixes to the pointer variants only. The
|
||||
same applies to C/C++ wrappers.
|
||||
|
||||
```nimrod
|
||||
type
|
||||
|
@ -82,12 +86,13 @@ changed in the future.
|
|||
- Exception and Error types should have the "Error" suffix.
|
||||
|
||||
```nimrod
|
||||
type UnluckyError = object of E_Base
|
||||
type UnluckyError = object of Exception
|
||||
```
|
||||
|
||||
- Unless marked with the `{.pure.}` pragma, members of enums should have an
|
||||
identifying prefix, such as an abbreviation of the enum's name. Since
|
||||
non-pure enum members can be referenced without
|
||||
non-pure enum members can be referenced without full qualification
|
||||
(in the form of ``MyEnum.fooValue``).
|
||||
|
||||
```nimrod
|
||||
type PathComponent = enum
|
||||
|
|
Loading…
Reference in New Issue