15 ms·
> Yes, the extra data being the length that is located in memory before the pointer. > You’re at the wrong level of indirection; the header in in the memory be
by clarry 6y ago
> Yes, the extra data being the length that is located in memory before the pointer.
> You’re at the wrong level of indirection; the header in in the memory before what the pointer points to, as in p - 1 rather &p - 1.
You are contradicting yourself. &p - 1 is before the pointer. p - 1 is before the pointee.
> I would prefer that this was not called a “fat pointer”, but the claim made above is that a pointer with any implicit data associated with it is “fat”.
> No data, but there is an implicit guarantee that it points to the data portion of a length-prepended array.
I think that's a borderline useless definition. In my C, there's an implicit guarantee that any pointer, in a context where it may be dereferenced, points to a valid object (as long as it's not NULL and there's no programming error causing it to point at nothing well defined). Usually it points at the start of a struct, sometimes it points at list node (or whatever) embedded in a struct and I might have to work my way back with offsetof. Either virtually all of my pointers are fat or none of them are. I go by that none of them are, because whatever data I have (implicit or explicit) is not a property of the pointers I use but of the data I point them to.