Skip to content

Commit

Permalink
Update NEP 1 to original style
Browse files Browse the repository at this point in the history
The original style was meant to enhance readability, a trait fairly important for a standard library.
  • Loading branch information
Varriount committed Sep 4, 2023
1 parent c5495f4 commit ae93ea2
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions doc/nep1.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ contexts. Furthermore, just as
[Python's style guide](http://legacy.python.org/dev/peps/pep-0008/) changes
over time, this style guide will too.

These rules will only be enforced for contributions to the Nim
codebase and official projects, such as the Nim compiler, the standard library,
and the various official tools such as C2Nim.
These rules will only be enforced for contributions to the Nim code base and
official projects, such as the Nim compiler, the standard library, and the
various official tools such as C2Nim.

----------------
Style Guidelines
Expand Down Expand Up @@ -256,34 +256,50 @@ Coding Conventions
Conventions for multi-line statements and expressions
-----------------------------------------------------

- Tuples which are longer than one line should indent their parameters to
align with the parameters above it.
- Tuples which are longer than one line should split their parameters across multiple lines, so that the definition resembles a standard "object" type definition.

```nim
type
LongTupleA = tuple[wordyTupleMemberOne: int, wordyTupleMemberTwo: string,
wordyTupleMemberThree: float]
LongTupleA = tuple[
wordyTupleMemberOne: int,
wordyTupleMemberTwo: string,
wordyTupleMemberThree: float
]
```

- Similarly, any procedure and procedure type declarations that are longer
than one line should do the same thing.

```nim
type
EventCallback = proc (timeReceived: Time, errorCode: int, event: Event,
output: var string)
proc lotsOfArguments(argOne: string, argTwo: int, argThree: float,
argFour: proc(), argFive: bool): int
{.heyLookALongPragma.} =
EventCallback = proc (
timeReceived: Time,
errorCode: int,
event: Event,
output: var string
)
proc lotsOfArguments(
argOne: string,
argTwo: int,
argThree: float,
argFour: proc(),
argFive: bool
): int
{.heyLookALongPragma.} =
```

- Multi-line procedure calls should continue on the same column as the opening
parenthesis (like multi-line procedure declarations).

```nim
startProcess(nimExecutable, currentDirectory, compilerArguments
environment, processOptions)
startProcess(
nimExecutable,
currentDirectory,
compilerArguments
environment,
processOptions
)
```

Miscellaneous
Expand Down

0 comments on commit ae93ea2

Please sign in to comment.