3 ms·
That's called using opaque pointers. It's pretty much what you do in C. ??? The empty interface is effectively dynamic typing, relying on runtime introspectio
by danieldk 11y ago
That's called using opaque pointers. It's pretty much what you do in C.
???
The empty interface is effectively dynamic typing, relying on runtime introspection. It does not hide any struct members (unless you make them private), you can simply enumerate them.
Opaque pointers in C provide a way to enforce static typing without exposing struct members and are effectively a method for information hiding.
So, I am wondering why you said that.
My other pet peeve is that a method with a non-pointer receiver that tries to modify the receiver object will silently drop those modifications on the ground, because the object is copied.
I agree. In fact, it is seldom that I actually want the non-pointer variant. If I don't modify the object, just give me a const modifier so that I can indicate that.
(Or reasoned from outside Go: the receiver should IMO always be passed by reference.)
- oconnor663 11y agoYou're right. I just toned down my language. What I meant to say is that doing away with type safety is an old idea, and its downsides are old too. You end up with code that's harder to read, because you can't tell what the types are supposed to be, and you run into bugs that show up far away from your mistakes.
- danieldk 11y agoI agree. Just wanted to check if I missed something :) (which happens often enough ;)).