4 ms·
Go doesn't really have pointers in the same manner as C, though, does it? As was as I was aware, you can only have a pointer to an actual object.
by sipefree 15y ago
Go doesn't really have pointers in the same manner as C, though, does it?
As was as I was aware, you can only have a pointer to an actual object.
- enneff 15y agoGo allows you to take the address of any value. You just can't do pointer arithmetic like you can in C. That is, you can't address uninitialized memory.
- ootachi 15y agoI assume you mean "any lvalue"? You can't take the address of rvalues, can you?
- deleted 15y ago[deleted]
- SteveMcQwark 15y agoEssentially, you are correct. Lvalues can have their address taken while rvalues cannot. However, the Go spec doesn't speak in terms of lvalue vs rvalue, it speaks in terms of the addressability of different kinds of expressions.
- enneff 15y agoGo doesn't define "lvalues," in the spec, but it does define "addressability." My comment would be more accurate if I had said "Go lets you take the address of any value in memory." (stack or heap)