justinmeiners / efficient-programming-with-components

Course notes for Alexander Stepanov's teachings on design and usage of C++ STL.
https://www.jmeiners.com/efficient-programming-with-components/
74 stars 6 forks source link

Chapter 4 `partial_sort` section could be a bit clearer #16

Closed aharrison24 closed 2 years ago

aharrison24 commented 2 years ago

I totally understand and support the idea of keeping Alex's idiomatic way of speaking, but I wonder if a little clarification would help in the partial_sort section of chapter 4. It says:


The video section corresponding to this is at https://youtu.be/VelLby6K2jQ?t=1305

I don't know what your policy is for putting words in Alex's mouth, but I wonder if something like the following would be clearer?



I'm not convinced it's reasonable (and I know my suggested text is super clunky as it stands), which is why I've raised an issue instead of a PR. Perhaps a footnote would be better?

justinmeiners commented 2 years ago

Here are a few thoughts:

In general I think it's OK to add to the exposition when things are not clear. Clarifications are good. If possible, I would try to order them to either lead with Alex's words, or lead with yours, then follow them up. For example:

What's the interface? It takes three iterators first, middle, and last. What does it do? It orders the elements so that first to middle contains the smallest elements from the entire range. Then it sorts those first elements.

The first three lines are his, mine are the implied response.

last is poorly named because it's one beyond the end, as you mentioned. However, this is a standard convention and all STL interfaces use the [first, last) idiom. So we should use last to refer to the iterator past the end of the range.

I have made a PR which I will ping you on.