On Saturday, 16 August 2025 at 15:44:09 UTC, Brother Bill wrote:
On Saturday, 16 August 2025 at 15:30:43 UTC, H. S. Teoh wrote:
On Sat, Aug 16, 2025 at 03:24:55PM +0000, Brother Bill via Digitalmars-d-learn wrote: [...]
So a good D developer should not store an invalid pointer address into a pointer, with the single exception of storing a pointer address just past a slice or array.

Where does it say this in the spec?  Because this is wrong.

D arrays carry length with them; they do not rely on pointers pointing past the allocated memory region.


T

Source: Programming in D book, page 432, chapter 68.8
Quote: It is valid to point at the imaginary element one past the end of an array.

That's poorly written and unnecessary verbosity, the code block is about slicing with indexes, and that's a logical coniquence of exclusive bounds.

Maybe that was early on in the range v iterator days and he was imagining c++ itorators may matter, they didnt, use ranges and slice quickly.

Maybe the spec and new gc should care, you shouldn't

The gc breaks clever pointers so the pressure to swap to indexes is even higher here. The safetyphiles will talk about bound checks being great ignore them, it's about solving off by one errors once and decreasing the users typing to 1 variable to pass around allowing for semi-tacit
              • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... Brother Bill via Digitalmars-d-learn
              • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... monkyyy via Digitalmars-d-learn
              • ... 0xEAB via Digitalmars-d-learn
              • ... 0xEAB via Digitalmars-d-learn
              • ... Brother Bill via Digitalmars-d-learn
              • ... Monkyyy via Digitalmars-d-learn
              • ... Brother Bill via Digitalmars-d-learn
              • ... Monkyyy via Digitalmars-d-learn
              • ... Monkyyy via Digitalmars-d-learn
              • ... Ali Çehreli via Digitalmars-d-learn
              • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
              • ... Monkyyy via Digitalmars-d-learn
  • Re: Pointers - I... Monkyyy via Digitalmars-d-learn
  • Re: Pointers - I... Paul Backus via Digitalmars-d-learn

Reply via email to