C++ Logo

sg12

Advanced search

Re: [isocpp-ext] Total order for pointer comparisons (again)

From: Nevin Liber <nevin_at_[hidden]>
Date: Fri, 24 Nov 2023 17:24:46 -0600
On Fri, Nov 24, 2023 at 4:34 PM Balog Pal via Ext <ext_at_[hidden]>
wrote:

> On 11/24/2023 10:35 PM, Alisdair Meredith via Ext wrote:
>
> I have been looking into writing a paper that suggests making a “flat address space” conditionally supported. In a flat address space, there is a total order for addresses, and pointers would compare only their addresses, without regard to provenance in the abstract machine. This would satisfy naive user expectations, removing another “embarrassment” from the language, while allowing for a compiler switch to re-enable the pointer provenance model and the (often surprising) optimization opportunities it grants.
>
> The language has a number of embarrassments, I disagree this is one. I'd
> even go to call embarrassment on the programmers who touch it with "naive"
> approach and start using features without first gain elementary
> understanding. That is sure recipe for disaster. And I also assert that
> making the move above would leave several traps behind. Teaching the
> provenance model seems a more promising way to get good and safe programs.
>
We've already had 35 years of teaching this. Why should anyone believe
that another 35 years of teaching will have a different result?

Non-experts see pointers as numbers, and expect them to behave as numbers.
We obviously won't do it everywhere (as it would grind optimization to a
halt), but giving them a conditionally supported flat address space seems
like a small concession to that mental model.

Experts, such as those designing our standard library (and our entire
committee for approving those designs), frequently get this wrong by using
operator< where they should be using std::less (as evidenced by Giuseppe's
examples). What chance do non-experts have?

If there is a reasonable chance this could go through, I'd encourage
Alisdair to finish the paper, and I would likely vote strongly in favor.
However, given that in the past whenever this subject comes up it generates
200+ messages before being abandoned, I have no clue if such an idea has a
reasonable chance or not. (Alisdair's idea is different compared with
previous ideas in that it would be conditionally supported.)
-- 
 Nevin ":-)" Liber  <mailto:nevin_at_[hidden] <nevin_at_[hidden]>>
+1-312-623-5420

Received on 2023-11-24 23:25:29