News for hackers. Stuff that matters.
Re:Tell HN: C Experts Panel – Ask us anything about C by loeg on Tuesday April 14, 2020 @11:37AM (#22867264)
Fat pointers in C would involve an ABI break for existing code, in that uintptr_t and uintmax_t would probably need to double in size.
Re:Tell HN: C Experts Panel – Ask us anything about C by rkangel on Tuesday April 14, 2020 @11:43AM (#22867352)
It would presumably involve a new type that didn't exist in the current ABI. Those pointers would stay the same, and the new (twice as big) pointers would be used for the array feature.
Re:Tell HN: C Experts Panel – Ask us anything about C by kazinator on Tuesday April 14, 2020 @12:46PM (#22868197)
On a given platform, the fat pointer type could have an easily defined ABI expressible in C90 declarations (whose ABI is then deducible accordingly).

For instance, complex double numbers can have an ABI which says that they look like struct { double re, im; };

Re:Tell HN: C Experts Panel – Ask us anything about C by professoretc on Tuesday April 14, 2020 @12:05PM (#22867643)
The point of uintptr_t is that it's an integer type to which any pointer type can be cast. If you introduce a new class of pointers which are not compatible with uintptr_t, then suddenly you have pointers which are not pointers.
Re:Tell HN: C Experts Panel – Ask us anything about C by _kst_ on Tuesday April 14, 2020 @02:24PM (#22869565)
No, uintptr_t is an integer type to which any object pointer type can be converted without loss of information. (Strictly speaking, the guarantee is for conversion to and from void*.) And if an implementation doesn't have a sufficiently wide integer type, it won't define uintptr_t. (Likewise for intptr_t the signed equivalent.)

There's no guarantee that a function pointer type can be converted to uintptr_t without loss of information.

C currently has two kinds of pointer types: object pointer types and function pointer types. "Fat pointers" could be a third. And since a fat pointer would internally be similar to a structure, converting it to or from an integer doesn't make a whole lot of sense. (If you want to examine the representation, you can use memcpy to copy it to an array of unsigned char.)

Re:Tell HN: C Experts Panel – Ask us anything about C by saagarjha on Tuesday April 14, 2020 @08:01PM (#22872929)
Note that POSIX requires that object pointers and function pointers are the same for dlsym.
Re:Tell HN: C Experts Panel – Ask us anything about C by loeg on Wednesday April 15, 2020 @02:30AM (#22875160)
Surely you're not arguing that a bounded array is in fact a function rather than an object? The distinction between function and object pointers exists for Harvard architecture computers, which sort of exist (old Atmel AVR before they adopted ARM), but are not dominant.
Re:Tell HN: C Experts Panel – Ask us anything about C by kazinator on Tuesday April 14, 2020 @12:47PM (#22868219)
You would be shocked by this language called C++ which is highly compatible with C and has "pointer to member" types that don't fit into a uintptr_t.

(Spoiler: no, there is no uintptr2_t).

Re:Tell HN: C Experts Panel – Ask us anything about C by loeg on Tuesday April 14, 2020 @12:35PM (#22868029)
Ditto uintmax_t. We do not want a uintmax2_t.
Re:Tell HN: C Experts Panel – Ask us anything about C by cesarb on Tuesday April 14, 2020 @11:45AM (#22867388)
Existing code would be using normal pointers, not fat pointers, so there would be no ABI break. New code using fat pointers would know that they fit into a pair of uintptr_t, so the size of uintptr_t would not need to change either.
Re:Tell HN: C Experts Panel – Ask us anything about C by loeg on Tuesday April 14, 2020 @12:36PM (#22868042)
I don't think we want a uintptr_t and uintptr2_t.
Re:Tell HN: C Experts Panel – Ask us anything about C by monocasa on Tuesday April 14, 2020 @03:43PM (#22870542)
IDK, it's not like it'd be an auto_ptr situation where you just don't use uintptr_t anymore and call the other one uintptr2_t. THere's different enough semantics that they both still make sesne.

Like, as someone who does real, real dirty stuff in Rust, usize as a uintptr equivalent gets used still even though fat pointers are about as well supported as you can imagine.