From de24cfd0c2cabe942217ea79be25af5f9ade5b01 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 4 Feb 2015 21:07:44 +0100 Subject: [PATCH] Updated Style Guide for Nim Code (markdown) --- Style-Guide-for-Nim-Code.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Style-Guide-for-Nim-Code.md b/Style-Guide-for-Nim-Code.md index f87654c..acd4e98 100644 --- a/Style-Guide-for-Nim-Code.md +++ b/Style-Guide-for-Nim-Code.md @@ -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