From d8a3935bc507a954032fc0458020a292236bd77f Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Thu, 16 Jun 2016 22:07:08 +0200 Subject: [PATCH] Updated Style Guide for Nim Code (markdown) --- Style-Guide-for-Nim-Code.md | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Style-Guide-for-Nim-Code.md b/Style-Guide-for-Nim-Code.md index a40a80e..7543a6c 100644 --- a/Style-Guide-for-Nim-Code.md +++ b/Style-Guide-for-Nim-Code.md @@ -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.