2 ms·
The author has a rather restrictive view of addressing modes. The C model of pointer reflects the limited addressing modes of the PDP-7 and PDP-11. It has the
by gumby 6y ago
The author has a rather restrictive view of addressing modes.
The C model of pointer reflects the limited addressing modes of the PDP-7 and PDP-11. It has the advantage of being easy to reason about but provides a limited set of functions. Some syntactic sugar is provided (e.g. `x[y]`) for access to indexed addressing, but anything more complex must be written by hand.
Counterintuitively, art of the role of a programming language is to restrict what you can do in the name of managing cognitive overhead (and is that not also the role of abstraction) and some of those trade offs are worth it (restricting bytes to being only 8 bits wide was, in retrospect, OK).
But there are programs that “can’t” be written in C. “Can’t” is in quotes because you can, but either have to escape into assembly code (e.g. there is no way to express SIMD intrinsics in C) or you have to say `resolve_ptr(foo)` rather than `*foo`).
So per pointers specifically:
Segmented memory models far predate the founding of intel corporation, and serve various purposes. One major one was indeed address space expansion, which thankfully is much less important than it used to be, but can also support valuable functionality hard or impossible to express in a language like c. For example, something like a setuid shared library. Overlapping segments can express other region smpemantics such as fast and slow memory
Even without segmentation the full value of the pointer can be used for other purposes such as type tagging; capabilities, signatures and other such security mechanisms; et al, none of which can be expressed in the C syntax.
(You can see that segmentation and pointer discrimination are really just different ways of describing the same mechanism to the hardware. However the semantics of a pointer may quite reasonably reflect other machine state, such as register state, that cannot be explicitly represented in C)
- mpweiher 6y ago> The author has a rather restrictive view of addressing modes. Not really, no. I thought a single prominent example would suffice to show how the industry moved towards the "flat address space" model and heaved a big sigh of relief after it had done so. > full value of the pointer can be used for other purposes such as type tagging [..] And this is very much dependent on being able to treat that pointer as an integer whose bits you can process...