Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add styleguide on use of with to CONTRIBUTING.md #294383

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lolbinarycat
Copy link
Contributor

Copy link
Member

@eclairevoyant eclairevoyant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as-is, this is too narrow of a scope (focusing on meta only). Perhaps this should be phrased to discourage with in any scope where its use may cause confusion. Clarifying the use in meta within a couple of bullets is fine to me, as long as we also explain (and focus on) the general policy.

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated

#### Use of `with`

`with` is a somewhat controversial feature of nix syntax, it can reduce repition, but easily can make code unreadable or buggy if used carelessly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps link to the nix.dev documentation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i considered it, but honestly, i don't think very highly of that guide, as it frankly lacks a lot of nuance, and feels like it might as well call with a deprecated feature. it doesn't provide any examples of times it would be ok or even encouraged to use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That guide can be improved too: https://github.com/NixOS/nix.dev

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be great to improve the article on with with acceptable uses and a better explanation of the problems. We can also link it from here for completeness already though.

I think this contributing section here is still valuable since it's more Nixpkgs specific and doesn't necessarily apply to Nix in general.

Co-authored-by: éclairevoyant <[email protected]>
@AndersonTorres
Copy link
Member

Voicing my opinion as a with-hater, I am against merging this pull request.
The merits of getting rid of with are mostly technical, not stylistic.

If the technical merits of banishing with to the most limited scopes (namely, a single line) don't convince everyone, then it is not good to force it over everyone - and way worse is to force it as a style.

@lolbinarycat
Copy link
Contributor Author

@AndersonTorres this PR does not "banish" the use of with at all. instead it only restricts its usage in specific scenarios that are widely considered confusing and hard to read.

for example, nested with makes it hard to tell where an identifier is coming from.

@lolbinarycat lolbinarycat marked this pull request as draft March 13, 2024 16:12
Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed in the docs team meeting today.

I don't have much of an opinion here, I'm also not a fan of with, and don't think it would be problematic to have it in the style guide, but I can also understand @AndersonTorres' arguments.

CONTRIBUTING.md Outdated

#### Use of `with`

`with` is a somewhat controversial feature of nix syntax, it can reduce repition, but easily can make code unreadable or buggy if used carelessly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be great to improve the article on with with acceptable uses and a better explanation of the problems. We can also link it from here for completeness already though.

I think this contributing section here is still valuable since it's more Nixpkgs specific and doesn't necessarily apply to Nix in general.

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-03-14-documentation-team-meeting-notes-113/41462/1

lolbinarycat and others added 2 commits March 14, 2024 16:03
Co-authored-by: Silvan Mosberger <[email protected]>
Co-authored-by: Silvan Mosberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation: style guide for use of with
6 participants