-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Clarify upfront that PartialOrd
is for strict partial orders
#140779
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
I'm going to move this to the libs-api agenda -- maybe we can find someone better suited to review this. It's not clear to me from the description in the issue (#140654) whether this is actually a semantic change or not in what we're promising -- it seems like it is maybe not, based on the diff, but I'm a little confused why we didn't land on this when initially landing the docs here. |
I do not believe this a semantic change. That would require the changed sentences to be normative, but that's impossible unless Also note that the docs later clarify that this is indeed for strict partial orders only: https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html#strict-and-non-strict-partial-orders |
cc @hanna-kruppe @RalfJung @tczajka @BartMassey @quaternic @rust-lang/lang |
I think this PR is a bad idea. The prefix "strict" for partial orders is used to distinguish |
While the trait does not require all implementations to have reflexivity, if you do want to implement a partial order that is reflexive (e.g., subset relation) then
Code that is generic over
I know what reflexivity is, but I'm not confident I would infer that the passing mention of "strict partial order" if I didn't know it already. (I’d probably be a bit confused for the reason @RalfJung explained) (Spelling out more corollaries is useful IMO, but I haven't checked the one added here.) |
The doc mentions:
In fact you cannot say a set (here, the set of all possible values of a type) form a partial order.
So I am joining @RalfJung on his point. However, the corollary is in fact true (using the duality of |
"Partial order" on its own always refers to a relation like ≤ on numbers (i.e. reflexive, antisymmetric, and transitive), so the original sentence is definitely misleading.
This is an argument against having the current sentence too.
Agreed, but then I'm not sure how to concisely describe what precisely
In my experience, when we say "X forms a partial order", this is short for "the usual order on X is a partial order".
Agreed, which is why I reported the issue and made the PR. In summary, I think we should at least agree that the original wording in the docs is wrong? |
I rarely encounter such terminology and would consider it sloppy. The typical thing people say in this case is "X is a poset". I am not particularly attached to the current wording. Picking the |
It seems best to me to describe this explicitly, i.e. to say in the documentation that usually the term partial order would require reflexivity, but that |
@traviscross The floating NaN example you linked is, as far as I can remember, the only irreflexive " |
Oh, it's definitely sloppy! But not any more than saying "X is a poset" :P
Well, I tried to keep the mathematical correspondence by identifying
I suspect people look to
I think calling out the exception would be good. However, I am worried that it might be misunderstood as a logical requirement with one weird exception. Maybe we should say something more like this: "Despite its name, or maybe "Despite its name, For completeness, here's the justification: Proposition: In a compliant implementation of |
I don't think that reflects the intent of this trait. Is is indeed truly okay for for this relation to not be reflexive.
Yeah that makes sense. |
|
Fixes #140654.