4 ms·
That would be a mess for interop with 8, 16, and 32-bit targets. What size should the length be? What happens when you exceed it? Nowadays you can just 32-bit a
by kevin_thibedeau 4y ago
That would be a mess for interop with 8, 16, and 32-bit targets. What size should the length be? What happens when you exceed it? Nowadays you can just 32-bit all the things and ignore most range issues. That luxury didnt exist in the 80s.
- tialaramex 4y ago> That would be a mess for interop with 8, 16, and 32-bit targets. What size should the length be? What happens when you exceed it? It works fine. The length has the same size as an address, the fat pointer being a pair of addresses is technically equivalent but has worse performance in practice so you should make it an (address, length) pair instead of course. You can't exceed this length because of the pigeonhole principle, basically just arithmetic.
- mananaysiempre 3y ago> The length has the same size as an address, the fat pointer being a pair of addresses is technically equivalent but has worse performance in practice so you should make it an (address, length) pair instead of course. Is it worse though? Serious question, I’ve been wondering for quite a bit. IME processing a string from the start is easier with a (start, end) pair (one operation instead of two when you chop off things from the start). You can’t use those in standard C because it reserves the right to blow up on pointer subtraction essentially randomly (ptrdiff_t overflow is UB, and the only requirement for ptrdiff_t is that it hold 2^15-1; C89 doesn’t even tell you what the maximum allowed value is), but that’s not a performance problem, and not a problem at all in a different language.