Updated Style Guide for Nim Code (markdown)
This commit is contained in:
parent
8dc1fd34dc
commit
d8a3935bc5
|
@ -60,12 +60,15 @@ changed in the future.
|
||||||
are not required to.
|
are not required to.
|
||||||
|
|
||||||
```nimrod
|
```nimrod
|
||||||
const aConstant = 42
|
const
|
||||||
const FooBar = 4.2
|
aConstant = 42
|
||||||
|
FooBar = 4.2
|
||||||
|
|
||||||
var aVariable = "Meep"
|
var
|
||||||
|
aVariable = "Meep"
|
||||||
|
|
||||||
type FooBar = object
|
type
|
||||||
|
FooBar = object
|
||||||
```
|
```
|
||||||
|
|
||||||
For constants coming from a C/C++ wrapper, ALL_UPPERCASE are allowed, but ugly.
|
For constants coming from a C/C++ wrapper, ALL_UPPERCASE are allowed, but ugly.
|
||||||
|
@ -86,7 +89,8 @@ changed in the future.
|
||||||
- Exception and Error types should have the "Error" suffix.
|
- Exception and Error types should have the "Error" suffix.
|
||||||
|
|
||||||
```nimrod
|
```nimrod
|
||||||
type UnluckyError = object of Exception
|
type
|
||||||
|
UnluckyError = object of Exception
|
||||||
```
|
```
|
||||||
|
|
||||||
- Unless marked with the `{.pure.}` pragma, members of enums should have an
|
- Unless marked with the `{.pure.}` pragma, members of enums should have an
|
||||||
|
@ -95,22 +99,24 @@ changed in the future.
|
||||||
(in the form of ``MyEnum.fooValue``).
|
(in the form of ``MyEnum.fooValue``).
|
||||||
|
|
||||||
```nimrod
|
```nimrod
|
||||||
type PathComponent = enum
|
type
|
||||||
pcDir
|
PathComponent = enum
|
||||||
pcLinkToDir
|
pcDir
|
||||||
pcFile
|
pcLinkToDir
|
||||||
pcLinkToFile
|
pcFile
|
||||||
|
pcLinkToFile
|
||||||
```
|
```
|
||||||
|
|
||||||
Non-pure enum values should use camelCase whereas pure enum values should use
|
Non-pure enum values should use camelCase whereas pure enum values should use
|
||||||
PascalCase.
|
PascalCase.
|
||||||
|
|
||||||
```nimrod
|
```nimrod
|
||||||
type PathComponent {.pure.} = enum
|
type
|
||||||
Dir
|
PathComponent {.pure.} = enum
|
||||||
LinkToDir
|
Dir
|
||||||
File
|
LinkToDir
|
||||||
LinkToFile
|
File
|
||||||
|
LinkToFile
|
||||||
```
|
```
|
||||||
|
|
||||||
- Uppercase acronyms (e.g. GPU) should be written in lowercase/capitalized: ``parseUrl`` rather than ``parseURL``, ``checkHttpHeader`` instead of ``checkHTTPHeader`` etc.
|
- Uppercase acronyms (e.g. GPU) should be written in lowercase/capitalized: ``parseUrl`` rather than ``parseURL``, ``checkHttpHeader`` instead of ``checkHTTPHeader`` etc.
|
||||||
|
|
Loading…
Reference in New Issue