This is a set of style guidelines which should be followed by contributors to the rapid game engine.
rapid tries to follow NEP 1's coding guidelines. Check them out here.
The following rules take precedence over NEP 1:
const
s should always use PascalCase
.
- For name-type pairs, put a single whitespace after the colon:
arg1: int
. - For calls, always use parentheses, refrain from using the command syntax
unless otherwise specified. In calls, do not put any whitespace before and
after the parentheses. Whenever it makes sense (eg. the object is mutated or
performs some action), use the dot call syntax
a.someProc(b)
. - For type conversions, use dot call syntax
a.SomeType
whenever possible, otherwise use either regular proc call syntaxSomeType(a + 2)
. Use command call syntaxSomeType a
for variable declarations, likevar i = int a / 2
. - Put whitespace around all operators except
..
,..<
and..^
. - Use
proc ()
instead ofproc()
for anonymous procs. - Order imports in three sections: system modules, Nimble modules, and own modules. Order each import in a section alphabetically.
- For other things, NEP 1 rules apply.
- Use implicit return only in one-line procs for formulas etc., use
result
everywhere else unless you need the flow control capabilities ofreturn
. - Use
ref object
s for "portable" objects, that is, objects which are always passed by reference from proc to proc (likeRGfx
)