Skip to content

Counted ranges abuse mathematical notation #2932

Description

@zygoloid

Counted ranges are presented as

[A, N)

but don't have the normal mathematical meaning; instead, they mean [A, A+N) (where the "+" means "the value that would be obtained by N applications of ++ to A" rather than operator+).

We should not abuse established mathematical notation in this way, and should find a different and unambiguous way to present counted ranges.

Activity

  1. CaseyCarter commented on Jun 14, 2019

    @CaseyCarter
    Contributor

    FWIW, +1 from me as the originator of this particular abuse of interval notation. It was originally less offensive since we used it in contexts where it was plain that the second member of the tuple is not a sentinel a la [i, 42), but we've had to avoid using it in less clear contexts ([i, n) isn't horrible, but [i, j) surely is). This context-sensitivity is a clear indicator that overloading the syntax is a bad idea.

  2. changed the title [-]counted ranges abuse mathematical notation[/-] [+]Counted ranges abuse mathematical notation[/+] on Jun 15, 2019
  3. tkoeppe commented on Jun 15, 2019

    @tkoeppe
    Contributor

    I agree that we should not overload existing, established notation for counted ranges.

    I don't have an "obvious" solution, but maybe we can define a slightly more elaborate device, maybe like “p + [0, N)” or so, to denote the set of iterators p + 0, p + 1, ..., p + (N - 1)? Something like a pair of a starting iterator plus the set of all valid offsets?

  4. added
    decision-requiredA decision of the editorial group (or the Project Editor) is required.
    on Aug 6, 2019
  5. removed
    decision-requiredA decision of the editorial group (or the Project Editor) is required.
    on Sep 10, 2019
  6. added
    decision-requiredA decision of the editorial group (or the Project Editor) is required.
    on Sep 26, 2019
  7. jensmaurer commented on Nov 4, 2019

    @jensmaurer
    Member

    Editorial meeting: Define range of iterators. "Elements in the range" means dereferencing the iterators in the range. Use "p + [0,N)".

  8. removed
    decision-requiredA decision of the editorial group (or the Project Editor) is required.
    on Nov 4, 2019
  9. self-assigned this
    on Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions