Hi Matthew, > Le 4 nov. 2019 à 05:27, Matthew Fernandez <matthew.fernan...@gmail.com> a > écrit : > > Hello Bison folk, > > I recently had a use case for comparing source positions coming out of a C++ > Bison-produced parser. While operator== and operator!= are implemented on the > position class [0], the ordering operators (<, <=, >, >=) are not. It was > relatively straightforward to implement these myself, but I was wondering if > these were of wider use and should live upstream in Bison’s position > implementation. Perhaps there is some history behind this or some deliberate > omission of these operators? Just wanted to ask if there’s a reason these > don’t already exist before thinking about posting a patch. I’m not subscribed > to the list, so please CC me in replies.
The semantics for line and columns are quite clear, so comparing Positions in the same file is quite well defined. But what should you do when the files are different? (And Locations are intervals, so there's no way to compare them totally in a natural order.) What we can do, though, is offer implementations for std::less, that would blindly apply the lexicographic order in both cases. But the case of file names remains troublesome: should we compare the pointer addresses (super fast, but non deterministic) or the pointees (super slow, but deterministic)?