More documentation for min_months_from_inner#7746
More documentation for min_months_from_inner#7746Manishearth merged 15 commits intounicode-org:mainfrom
Conversation
| // The Hebrew Metonic cycle has leap years in year 3, 6, 8, 11, 14, 17, and 19, | ||
| // i.e., leap year gaps of +3, +3, +2, +3, +3, +3, +2. |
There was a problem hiding this comment.
be explicit about the boundary, either add year 0 or year 22
There was a problem hiding this comment.
Year 19 is the boundary. This is every 19 years.
poulsbo
left a comment
There was a problem hiding this comment.
@robertbastian should your comments re: the EastAsianTraditional calendar
Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
5530d53 to
a60b9bc
Compare
a60b9bc to
1374201
Compare
| /// | ||
| /// This crate currently provides [`Rules`] for [`China`] and [`Korea`]. | ||
| /// | ||
| /// Currently, implementations of this trait must produce calendars that |
There was a problem hiding this comment.
ok, now show that China and Korea obey this invariant
There was a problem hiding this comment.
No.
I am mostly convinced the code currently upholds this property. I am not convinced enough to "prove" it, I am convinced from a read through of the code, enough that I am satisfied with landing that code.
My original plan was to properly sit down and figure out China and Korea (such that there is a constant time error). I haven't had time to do that (and didn't plan to do that for 2.2), but Alan opened his PR in the meantime. I am doing followups for his PR because I have thought about the Hebrew stuff and wanted to write it down. Me choosing to do those followups is not me signing up for more work here, if you want to disagree with that PR feel free to disagree with it and discuss further, or open a PR to undo the Chinese part of it.
I already recommended another route above: instead of debug asserting after computing min_months, we can set min_months to sign when that assertion fails. That is the only thing that needs to change to turn this from a hard requirement into a soft "optimal behavior" one. If you care about this, go ahead and do that.
There was a problem hiding this comment.
Well you merged Alan's PR before it was thoroughly reviewed, so you're kind of on the hook for this now.
Now you're adding an invariant to the type without showing that it holds. The safe thing to do would be to remove the invariant, go back to returning 12 * years and figure this out later.
I already recommended another route above: instead of debug asserting after computing min_months, we can set min_months to sign when that assertion fails. That is the only thing that needs to change to turn this from a hard requirement into a soft "optimal behavior" one.
Cool, we could have discussed that on the PR that added this code. I don't want to do this work either, so let's revert #7739.
There was a problem hiding this comment.
I am fine doing small changes here. Please do not ask me to do large changes as a part of a followup PR that I am making as a courtesy.
There was a problem hiding this comment.
I'm quite confident that Pinqi follows this invariant, because it adds a leap month with an exact period, I think every 33 months.
There was a problem hiding this comment.
I'm quite confident that Pinqi follows this invariant, because it adds a leap month with an exact period, I think every 33 months.
Please don't call the simple approximation Pinqi, it's not that because it's based on the Gregorian year.
I'm quite confident too, but I don't want to find out when Temporal is experiencing panics in half a year. We use several approximations in that code.
Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
sffc
left a comment
There was a problem hiding this comment.
This improves the status quo by documenting the invariant. We should also test the invariant against built-in calendars, and the debug assertions should catch it for user calendars.
sffc
left a comment
There was a problem hiding this comment.
No, the last commit pushed a few seconds ago regresses performance relative to what landed on main.
Yes but it's provably correct. Please let's not go back to yoloing code with debug assertions, that has been painful enough to clean up in the past. |
|
I am going to undo my undoing so that this PR is purely a docs fix. We should land this, and we can separately discuss the chinese invariant. I'll make a separate PR for that. I am rather frustrated with this ping ponging on a small courtesy PR. |
And it's scope creep for this PR. |
|
Especially since the fix to avoid the debug assertions is not that big a deal. |
I'm rather frustrated with #7739 being merged without my review. When I left work on Friday that PR was still actively being worked on, and I had drafted review comments. Now I'm the bad guy for asking for these changes to be reverted. |
No. You could still post the review comments. I'm just frustrated that I'm being asked to fix these in this PR. |
You're adding invariants that might not actually be true, thereby legitimizing problematic code. I'm happy to approve this without the east asian changes. |
You said: "We either need to add a requirement that the rules insert a leap month at least every three years". I followed that feedback. Turned out you wanted the associated proof as well, which I do not have right now. Okay, fine, I'll undo that change there. |
robertbastian
left a comment
There was a problem hiding this comment.
Turned out you wanted the associated proof as well
Yes I generally expect that when adding an invariant.
|
I think the version of the PR that documented the invariant was better, because we should write down our assumptions, but the PR here is still an improvement over the status quo so I approve |
Improving docs from unicode-org#7739 --------- Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
Improving docs from #7739
Changelog: N/A