3 ms·
"the general presentation of good ole shoot-yourself-in-the-foot pointers... presence of interface{} as an analog of void*" Go doesn't have "shoot yourself in
by jerf 7y ago
"the general presentation of good ole shoot-yourself-in-the-foot pointers... presence of interface{} as an analog of void*"
Go doesn't have "shoot yourself in the foot" pointers. For that, you need pointer arithmetic, and Go doesn't have that. (Outside of the "unsafe" library.) interface{} may be an analog of void∗, but it lacks the failure in C where casting something to void∗ loses all type information; in Go, if you put an "string" into an interface{}, the runtime still knows it's a "string" and you can't put it into any sort of strongly typed variable except a string. The runtime/virtual machine Go implements knows the types of all values at all times.
I really wish the Go designers had called their pointers "references". Considered across the entire landscape of what various programming languages call "pointers" and "references", there's substantial overlap but I think Go's pointers are closer to the center of the "references" cluster than the "pointers" one.