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

[time.clock.cast.sys],[time.clock.cast.utc] Use Duration2 for clarity. #4565

Merged
merged 2 commits into from May 29, 2021

Conversation

StephanTLavavej
Copy link
Contributor

Fixes #4564.

@StephanTLavavej
Copy link
Contributor Author

Maybe this needs to be shorter, like Dur2, to avoid failing checks? I am unfamiliar with the error here.

@CaseyCarter
Copy link
Contributor

CaseyCarter commented Mar 29, 2021

Maybe this needs to be shorter, like Dur2, to avoid failing checks? I am unfamiliar with the error here.

"Overfull \hbox" is latex telling us there's a long-and-unbreakable word at the end of a line overflowing ~10pts (in these cases) into the margin, and that wrapping it to the next line would leave too much whitespace on the current line. In other words, it can't find a way to flow this text that doesn't look terrible within the constraints it has been given.

The fix is for a human to look at the generated output to see what the problem word is, and either introduce a discretionary hyphen with \- ("If you have to break this word break it here and add a hyphen"), or a plain discretionary linebreak with \brk{} (ditto, but with no hyphen - generally used for code), or by rephrasing the prose so the problem word doesn't encroach into the right margin.

See StephanTLavavej#1.

\tcode{SourceClock::to_sys(t)} returns a \tcode{sys_time<Duration>},
where \tcode{Duration} is a valid \tcode{chrono::duration} specialization.
\tcode{SourceClock::to_sys(t)} returns a \tcode{sys_time<Duration2>},
where \tcode{Duration2} is a valid \tcode{chrono::duration} specialization.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a normative change to me. Before, I read this as requiring Duration to be a valid specialization of chrono::duration and requiring SourceClock::to_sys(t) to return sys_time<Duration>. The after condition is obviously quite different, allowing SourceClock::to_sys(t) to return a sys_time parameterized with a completely different specialization of chrono::duration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read this as [...] requiring SourceClock::to_sys(t) to return sys_time<Duration>.

That's a plausible reading on its face, but based on my experience implementing this, I think it's too restrictive to be the intended meaning. There's no guarantee that the input Duration will be able to represent the difference between the two clock epochs, so in general there must be some flexibility to return a different duration specialization. That's why all the built-in conversions return a common_type_t<Duration, seconds>. Otherwise, something reasonable like clock_cast<gps_clock>(sys_days{1d / January / 2020y}) won't work if the input and output Duration have to be the same.

But I'm happy to help, if desired, if people prefer to see this escalated to an LWG issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'm happy to help, if desired, if people prefer to see this escalated to an LWG issue.

We've already gone to the trouble to prepare a PR, I suggest waiting for word from one of the editorial team before dropping this and resubmitting as an LWG issue. My instincts for what the Project Editor will consider to be an editorial change are not infallible.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Mar 30, 2021
@jensmaurer
Copy link
Member

The "where ..." phrase seems to imply we're talking about a fresh Duration here, but there is another Duration in scope that makes that a stretch. @jwakely , did you implement this?

@jwakely
Copy link
Member

jwakely commented Mar 31, 2021

We have not implemented this yet.

@HowardHinnant
Copy link

Thanks for bringing this to my attention @jensmaurer.

This does look like a defect to me, and the fix looks correct to me. Somehow when translating the original documentation to the proposed wording, I introduced this bug.

Here is the original documentation: https://howardhinnant.github.io/date/tz.html#clock_cast Search for:

"template
auto
operator()(const utc_time& t) const
-> decltype(DestClock::from_utc(t));"

Remarks: This function does not participate in overload resolution unless DestClock::from_utc(t) is well formed. If DestClock::from_utc(t) does not return time_point<DestClock, _some duration_> the program is ill-formed.

I.e. it was some duration that was intended instead of Duration, and the proposed fix subs in Duration2 where some duration was in the original documentation.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Apr 4, 2021
@jensmaurer
Copy link
Member

@tkoeppe, @jwakely: Any opposition to fixing this editorially, given that @HowardHinnant said the pull request manifests the intended behavior?

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Apr 21, 2021
@jensmaurer
Copy link
Member

jensmaurer commented Apr 30, 2021

Editorial meeting 2021-04-30: Given the opinions of the stakeholders, this is considered editorial.

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 30, 2021

@jwakely, @CaseyCarter: Please take note that we're making this change editorially.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Apr 30, 2021
@jwakely
Copy link
Member

jwakely commented Apr 30, 2021

Sorry for the late comment, but couldn't this be further simplified? What is a "valid" duration? [time.duration.general] already says that invalid specializations are ill-formed, and time_point requires a duration. So isn't the requirement here just that it returns a time point with the right clock?

@jwakely
Copy link
Member

jwakely commented Apr 30, 2021

Specifically, I think that both instances of "where Duration2 is a valid chrono::duration specialization" could be changed to "for some Duration2" with no change in meaning.

@HowardHinnant
Copy link

No opinion either way here.

@jensmaurer
Copy link
Member

I appreciate the concerns, and I sympathize with them, but given the rather invasive nature (from a "squint the wrong way" standpoint) of this pull request, I'd suggest to merge it as-is and have a separate issue to look for "valid specializations" in all of [time]. (I suspect there are more of these).

@jwakely
Copy link
Member

jwakely commented May 29, 2021

That works for me

@jwakely
Copy link
Member

jwakely commented May 29, 2021

The only other cases are [time.clock.cast.sys] and [time.clock.cast.utc]. This change seems consistent with the language there. I think we could remove "valid" there without changing the meaning.

@tkoeppe
Copy link
Contributor

tkoeppe commented May 29, 2021

@jwakely Please let's follow up on the simplification suggestions. I created #4613 to track that.

@StephanTLavavej StephanTLavavej deleted the duration2 branch May 31, 2021 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[time.clock.cast.sys] and [time.clock.cast.utc] reuse "Duration" confusingly
7 participants