[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Further C++ operators for position

From: Hans Åberg
Subject: Re: Further C++ operators for position
Date: Mon, 4 Nov 2019 21:16:59 +0100

> On 4 Nov 2019, at 18:12, Akim Demaille <address@hidden> wrote:
>> Le 4 nov. 2019 à 17:03, Matthew Fernandez <address@hidden> a écrit :
>> The std::less implementation you suggest is to also lexicographically 
>> compare the filenames themselves? I’m not sure this makes sense, because 
>> source positions from two different files aren’t really orderable at all.
> The point of defining std::less is to have an easy means to insert positions 
> in a sorted container, say std::map.  Now, the order in itself is well 
> defined, but my not reflect the order the user would like to see.
> To be clear: I don't have a problem with std::less which I see as an 
> implementation detail, but operators such as <= and the like are different: 
> they express a total order that we can't implement easily.  

The total order is expressed via std::less in containers such as std::map, with 
undefined results if not fulfilling the specs for that.

> In addition, think of C where you also have main.c that #include "foo.h" 
> somewhere, which results in main.c:1 (i.e., line 1) < foo.h:1 < ... < 
> foo.h:42 < ... < main.c:3.

Here the files are stacked, and if the nested files are closed after being 
read, the location pointers are dead.

> If we want a total order here, it's actually easy: positions should have a 
> counter somewhere which is the *total* "offset" since the first byte of the 
> first file.  Or something like that.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]