News for hackers. Stuff that matters.
Re:Abstraction: Not what you think it is by wvenable on Wednesday March 30, 2022 @01:17PM (#30858088)
Maybe the data type isn't a pointer, maybe it's an integer handle to a kernel object. And you may still need to free/release it even though it's not a pointer at all.

There are plenty of APIs that have similar semantics (connect/disconnect) that must be followed. And even if something is a pointer doesn't mean you can just free() it -- you might need to use whatever method the API provides to get proper operation.

This is the main abstraction mechanism in C programs -- the abstract data type. A piece of data you pass around but never know the innards of.

Re:Abstraction: Not what you think it is by ncmncm on Wednesday March 30, 2022 @01:44PM (#30858425)
File descriptors are an example of such a type. In good code they are carefully kept equal to -1 when not open, and are carefully identified, and not leaked.

When something has reference semantics but isn't an actual pointer, that is an extra fact that the reader of code needs to know in order to reason correctly about it. That is, thus, a burden above what would be needed for an actual pointer. It is a burden that is harmful to impose entirely unnecessarily.

Re:Abstraction: Not what you think it is by Koshkin on Wednesday March 30, 2022 @02:10PM (#30858731)
Pointers aren't special, and memory is not the only resource that requires managing.
Re:Abstraction: Not what you think it is by ncmncm on Thursday March 31, 2022 @06:59AM (#30865817)
Pointers are special. They have implicit conversions, and a wide variety of pre-defined operations, typically only a few of which are correct for any particular use.

Managing any resource is trivial with destructors. If you need to manage a resource, a pointer is a poor way to do it.

In C, you have a poverty of choices, but people are anyway used to being careful around pointers.