Updated Style Guide for Nim Code (markdown)

This commit is contained in:
Andreas Rumpf 2016-06-16 22:07:08 +02:00
parent 8dc1fd34dc
commit d8a3935bc5
1 changed files with 21 additions and 15 deletions

View File

@ -60,12 +60,15 @@ changed in the future.
are not required to.
```nimrod
const aConstant = 42
const FooBar = 4.2
const
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.
@ -86,7 +89,8 @@ changed in the future.
- Exception and Error types should have the "Error" suffix.
```nimrod
type UnluckyError = object of Exception
type
UnluckyError = object of Exception
```
- 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``).
```nimrod
type PathComponent = enum
pcDir
pcLinkToDir
pcFile
pcLinkToFile
type
PathComponent = enum
pcDir
pcLinkToDir
pcFile
pcLinkToFile
```
Non-pure enum values should use camelCase whereas pure enum values should use
PascalCase.
```nimrod
type PathComponent {.pure.} = enum
Dir
LinkToDir
File
LinkToFile
type
PathComponent {.pure.} = enum
Dir
LinkToDir
File
LinkToFile
```
- Uppercase acronyms (e.g. GPU) should be written in lowercase/capitalized: ``parseUrl`` rather than ``parseURL``, ``checkHttpHeader`` instead of ``checkHTTPHeader`` etc.