rephrase best practices for clarity#790
rephrase best practices for clarity#790proofconstruction merged 1 commit intoNixOS:masterfrom wamirez:master
Conversation
proofconstruction
left a comment
There was a problem hiding this comment.
Reviewed in documentation team meeting. This simplifies the section.
| - It's possible to introduce a hard to debug error `infinite recursion` when shadowing a name, the simplest example being `let b = 1; a = rec { b = b; }; in a`. | ||
| - Combining with overriding logic such as the [`overrideAttrs`](https://nixos.org/manual/nixpkgs/stable/#sec-pkg-overrideAttrs) function in {term}`Nixpkgs` has a surprising behaviour of not overriding every reference. | ||
| A common pitfall is to introduce a hard to debug error `infinite recursion` when shadowing a name. | ||
| The simplest example for this is: `let a = 1; in rec { a = a; }`. |
There was a problem hiding this comment.
| The simplest example for this is: `let a = 1; in rec { a = a; }`. | |
| The simplest example for this is: `let a = 1; in rec { a = a; }` |
With a colon in between we probably don't need the full stop, as that tends to interfere with reading the expression.
Alternatively, but that could give it too much emphasis right before the tip:
| The simplest example for this is: `let a = 1; in rec { a = a; }`. | |
| The simplest example for this is: | |
| ```{code-block} nix | |
| let a = 1; in rec { a = a; } | |
| ``` |
We may want to add <details> because it may not be apparent what's trivially weird about it:
One might expect that the value assigned in the attribute set is taken from the surrounding
letbinding, but names from therecscope take precedence.
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-11-06-documentation-team-meeting-notes-92/35243/1 |
Added some changes to
source/guides/best-practices.md.recexample.