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

[limits] Integrate section [limits.numeric] into section [numeric.lim… #1159

Merged
merged 1 commit into from Dec 15, 2016

Conversation

jensmaurer
Copy link
Member

…its].

Fixes #785.

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 30, 2016

This would be a nice cleanup. @jwakely, @zygoloid, any objections to the loss of a stable name?

@jwakely
Copy link
Member

jwakely commented Nov 30, 2016

Fine by me.

@W-E-Brown
Copy link
Contributor

W-E-Brown commented Nov 30, 2016 via email

@jensmaurer
Copy link
Member Author

jensmaurer commented Nov 30, 2016

@W-E-Brown: Hm... But the introductory sentence in the first paragraph only mentions numeric_limits, but the synopsis also has float_round_style and float_denorm_style. At this point, it's not clear these are related to the numeric_limits template. That said, I do admit there is little besides numeric_limits in the [limits] section. 18.3.1 already has an introductory sentence that says " specs follow".

Other opinions?

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 30, 2016

The entire structure of 18.3.2 is weird. Anywhere else in the Standard we would structure it like this:

  • 18.3.2: Numeric something something
    • 18.3.2.1: Header <numeric> synopsis
    • 18.3.2.2: Class template numeric_limits
      • Class template definition
      • 18.3.2.2.1: numeric_limits members
      • 18.3.2.2.2: numeric_limits specializations
    • 18.3.2.3: Type float_round_style
    • 18.3.2.4: Type float_denorm_style

That is, the synopsis is the first sibling in a subclause that describes the things that are listed in the synopsis. That's how we do it for most other library components. A "General" section could optionally precede the synopsis, but only if there's something useful to say. (I think the origin of "General" sections lies in the ISO drafting directives which say never to have "mixed" content in a subclause, i.e. paragraphs and sub-subclauses.)

@tkoeppe
Copy link
Contributor

tkoeppe commented Nov 30, 2016

In a hypothetical world, and given that we now have full synopses for the C library, I could even imagine the following structure:

  • 18.3: Implementation properties of arithmetic types
    • 18.3.1: General
    • 18.3.2: Header <limits> synopsis
    • 18.3.3: Header <climits> synopsis
    • 18.3.4: Header <cstdint> synopsis
    • 18.3.5: Header <cfloat> synopsis
    • 18.3.6: Class template numeric_limits
      • Class template definition
      • 18.3.6.1: members
      • 18.3.6.1: specializations
    • 18.3.7: Floating point rounding and extreme values
    • 18.3.8: Integer types [##]
    • 18.3.9: C library [##]

The last two sections, marked [##], are probably not necessary at all, since their only contained paragraph may as well stay with the synopsis.

@jensmaurer
Copy link
Member Author

A mild issue with all the presentation options so far is that float_round_style and float_denorm_style are used in the definition of numeric_limits. It would be good to introduce/explain them before the numeric_limits template. Also, when extracting the synopses, 18.3.6 "C library" becomes empty.

I'd also like to point out that we have a subsection "C library" in clause 27, too, and we just have the synopses under this subsection with a one-sentence "same as in C" statement. Ok, but elsewhere (e.g. in the "strings" clause), the C library stuff is just adjoint to the C++ stuff, without particularly highlighting it's from C.

@jensmaurer
Copy link
Member Author

Ok, I've done something along @tkoeppe 's "hypothetical world". I like it now. (Note that I expressly only moved sections, added/removed subsection headings, and fixed cross-references.)

@W-E-Brown
Copy link
Contributor

No longer hypothetical, eh? I like it.

 - Change order of subsections.
 - Remove [limits] and [c.limits] subsection headings.
 - Move descriptions of numeric_limits members and specializations as
   subsections under the description of the primary class template.
 - Add sectioning comments to the <limits> synopsis.

Fixes cplusplus#785.
@jensmaurer
Copy link
Member Author

Rebased.

\tcode{numeric_limits}
template, specializations shall define these values in such a way
that they are usable as
constant expressions.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this paragraph? What alternative is being excluded here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, there are member functions declared "static constexpr" (such as infinity()), and users can specialize numeric_limits for their own types. Since a function can be declared constexpr, yet not be usable in a constant expression, my guess is that this essentially requires that "T" doesn't access global or volatile variables when copied. (Such a copy is required for the return value of infinity(), for example.)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, this applies to user specializations. Seems weird to put a "shall" on that, but OK.

Copy link
Member Author

Choose a reason for hiding this comment

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

See also LWG 2833 "Library needs to specify what it means when it declares a function constexpr".

Copy link
Member

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

One question, but I'm fine with merging this as-is.

@zygoloid zygoloid merged commit f8904bd into cplusplus:master Dec 15, 2016
@tkoeppe
Copy link
Contributor

tkoeppe commented Dec 15, 2016

Tip for the future: Please always check the overfull box status for your proposed change:

fgrep -e Overfull -e .tex std.log

@jensmaurer
Copy link
Member Author

Alerted Marshall Clow (LWG chair) to this change.

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.

None yet

5 participants