I know some people have expressed different preferences, but just to illustrate 
another perspective, I think at the module level it's preferable to indent 
what's after `import`, `var`, `const`, `type` on a different line, even if it 
the whole structure could be formatted as a single line, that's because I 
interpret the `type`, `const`, etc at the module level as: "Hey, I'm declaring 
a new module section of vars|types|consts here", and not "I'm declaring a type 
here, a var there, etc". Again, I'm taking about the module level here.

I think this is prettier and easier to parse visually:
    
    
    import
      std/strformat,
      pointmath
    
    type
      Point = distinct int
    
    var
      x = 1.Point
      y = 2.Point
    
    const
      prettyFormat = true
    
    proc `+`(x: Point; y: Point): Point {.borrow.}
    proc `$`(x: Point): string {.borrow.}
    
    echo &"Add two points: {1 + 2}"
    
    
    Run

than this:
    
    
    import std/strformat, pointmath
    
    type Point = distinct int
    
    var
      x = 1.Point
      y = 2.Point
    
    const prettyFormat = true
    
    proc `+`(x: Point; y: Point): Point {.borrow.}
    proc `$`(x: Point): string {.borrow.}
    
    echo &"Add two points: {1 + 2}"
    
    
    Run

Thoughts?

Reply via email to