Coder Social home page Coder Social logo

Comments (7)

DavHau avatar DavHau commented on June 3, 2024 4

We should adopt whatever style is predominant in nixpkgs.

Does that mean you prefer adopting predominant style over good/useful style?

Some of the stuff which is predominant right now is not good and negatively impacts editing workflow / git diffs etc., see for example: #248

If the ultimate goal is to establish a standard that is going to be enforced at some point in the future, shouldn't the first priority be to make that standard good and useful instead of adopting what is predominant right now?

For the current issue, I suggest that we just allow both styles (containers with and without space), because it really doesn't matter if there is a space or not. Maybe limiting the number of spaces to 1 could make sense.

from nixpkgs-fmt.

kamadorueda avatar kamadorueda commented on June 3, 2024 3

Some people see a formatter as a way to make code more beautiful, but beauty is subjective

So my perspective of a formatter is that it's a tool that avoid discussions of style A vs style B and standardizes code,
so people can focus on the soul of the software instead of its skin

To me, having a rule, even if ugly to some people (again, ugliness is subjective)
is more valuable than not having a rule

from nixpkgs-fmt.

zimbatm avatar zimbatm commented on June 3, 2024 2

When we wrote the rule my impression was that the space was predominant. We should adopt whatever style is predominant in nixpkgs.

from nixpkgs-fmt.

mohe2015 avatar mohe2015 commented on June 3, 2024 1

I think no space also has the advantage that it takes less horizontal space. And probably (but this is highly unscientific) your brain has it easier to parse it as its kind of "one token"

from nixpkgs-fmt.

r-burns avatar r-burns commented on June 3, 2024

Even putting personal preference aside, from a purely descriptivist standpoint no-space appears to be the predominant style in Nixpkgs:

$ cd nixpkgs

$ rg '\[ \]' | wc -l
2797

$ rg '\[\]' | wc -l
11617

$ rg '\{ \}' | wc -l
16714

$ rg '\{\}' | wc -l
23533

from nixpkgs-fmt.

kamadorueda avatar kamadorueda commented on June 3, 2024

Proposed implementation: #280

from nixpkgs-fmt.

zimbatm avatar zimbatm commented on June 3, 2024

Does that mean you prefer adopting predominant style over good/useful style?

It depends on how clear the improvement is. For example, here it could make things less consistent:

{
   listA = [];
   listB = [ 1 2 3 ];
}

vs

{
   listA = [ ];
   listB = [ 1 2 3 ];
}

In the second case, the whitespace is always present. To me, that seems like a simpler rule. I think most people are used to no spaces at all, in both listA and listB, coming from other languages and so would more readily adopt the first list.

It feels a bit nit-picky either way and I'm ready to change my mind. My only concern is that we aren't really representative of the community as a whole. That's when I think we should default to whatever is the most common. @r-burns showed that the no space is more common for empty lists so I guess we can go down that route.

from nixpkgs-fmt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.