docs: add explanation to sort primop#14552
Conversation
src/libexpr/primops.cc
Outdated
| If a is NOT less than b; b is NOT less then a; a and b are equal according to the comparator. | ||
| If b is equal to c then it follows that a is equal to c |
There was a problem hiding this comment.
| If a is NOT less than b; b is NOT less then a; a and b are equal according to the comparator. | |
| If b is equal to c then it follows that a is equal to c | |
| First, let us define *equivalence* with respect to some comparator: | |
| If x is *not* less than y and x is *not* less then y, then x and x are equivalent according to the comparator. | |
| Having done that, now we can define the transitivity of this equivalence: | |
| If a is equivalent to b and b is equivalent to c, then it follows that a is equivalent to c, |
I think using different variables here make the prose much less confusing. Your version IMO made the mistake of extending the a: b: ... scope too far: the second a and b are not the same.
There was a problem hiding this comment.
Okay, i can make the sentence more correct in that regard. But my other point was to avoid the term transitivity in its own definition. Because at that point i (or the reader) doesn't understand what it means.
I also wonder if we need to define the eq function, when the point is to explain the concept, we shouldn't over formalize, but make sure the required property is understood by keeping the explanation simple.
There was a problem hiding this comment.
Sentence updated. Can you check again ?
The code is valid nix and can be e.g. copied into the repl. |
8318e95 to
2c0628d
Compare
|
@xokdvium @Ericson2314 updated the PR. Can you check again? |
Code alone isn’t enough. clear prose is needed to explain intent and prevent misinterpretation. |
Motivation
Reading through the docs of sort. I found them a bit hard to understand.
I think the code examples could benefit from some prose that explains them upfront.
It is non-obvious how to interpret the code. especially
->does this mean nix'simplicationoperator?Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.