`nph` 0.3 is out! Binaries from the [release 
page](https://github.com/arnetheduck/nph/releases)

  * Back to `,` as parameter separator - this helps compatibility with inline 
procs due to a parsing quirk where `;` gets eaten by the inline parser while 
`,` (mostly) does not
  * New manual at <https://arnetheduck.github.io/nph/> with a few highlights 
from the style choices (more to come, probably)
  * 100% Nim compiler/stdlib compatibility
  * Assorted bugfixes



The [nph](https://github.com/arnetheduck/Nim/tree/nph) branch shows the 
formatted language sources - similarly, here's a commit from another project: 
<https://github.com/status-im/nimbus-eth2/commit/2836af94fe320255648de1e0d87f157ed757ac3b>

Although `,` by far is the most popular choice for parameter separator, some 
people have mentioned a preference for `;` as parameter separation for clarity, 
which to a certain extent I can agree with - one thing of note is that `nph` 
will format complex or long proc parameter lists with newlines, thus providing 
a different way of making complex proc's readable - here's an example:

Original:
    
    
    proc getNullValueAuxT(p: BProc; orig, t: PType; obj, constOrNil: PNode,
                          result: var Rope; count: var int;
                          isConst: bool, info: TLineInfo)
    
    
    Run

Formatted:
    
    
    proc getNullValueAuxT(
      p: BProc,
      orig, t: PType,
      obj, constOrNil: PNode,
      result: var Rope,
      count: var int,
      isConst: bool,
      info: TLineInfo,
    )
    
    
    Run

This long-form style still groups parameters of the same type (`orig, t`) but 
with a newline instead of `;` \- it is of course a matter of taste to use this 
many lines, but hey - it's also a good sign that some refactoring is due.

As noted previously, we can have any two of happy `;` users, happy `,` users 
and opinionation - `nph` chooses the latter two - not that I think `;` is a bad 
choice necessarily - it does, as was pointed out in the v0.2 thread, have a 
venerable history of several now extinct languages behind it and one could 
argue it fits the AST structure slightly better - that said, implementation 
concerns and popularity (smaller format-existing-code-diff) tipped the scales 
here - if someone wants to go on a crusade here and rework the grammar to be 
less ambiguous, nph will follow - until then...

Anyway, what's nice about this release is that apart from the comma, things 
have settled down quite a bit with actual formatting changes - still a few 
fixes to do, in particular around inline expressions (to make simple ones less 
clunky), but given how well it works already (hey, we're still at 0.3..) with 
most source code I'm testing it on, hopefully we're at a structurally good 
point and there's now time to focus on polish.

In other news, the proposal to "bless" hanging indent (over vertical alignment) 
in [NEP1](https://github.com/nim-lang/Nim/pull/23105) got accepted meaning that 
the `nph` output by and large is in line with community guidance on this 
subject which is nice ;)

Past threads:

  * [v0.2](https://forum.nim-lang.org/t/10793)
  * [Introducing...](https://forum.nim-lang.org/t/10754)


Reply via email to