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

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Mar 9, 2024
Copy link
Contributor

@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
Contributor

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
Contributor

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 <848000+eclairevoyant@users.noreply.github.com>
@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 <github@infinisil.com>
Co-authored-by: Silvan Mosberger <github@infinisil.com>
@Qyriad Qyriad added 6.topic: best practices 6.topic: documentation Meta-discussion about documentation and its workflow labels May 26, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: best practices 6.topic: documentation Meta-discussion about documentation and its workflow 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation: style guide for use of with
7 participants