You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In chapter 2, when introducing pointers, the book says:
A pointer is a memory address; it's the location of where to find the actual value. It's a level of indirection. Loosely, it's the difference between being at a house and having directions to the house.
Now, I'm by no means an experienced programmer and just started with Go two hours ago. I do have a little bit of C experience, though. And I think that the last sentence in the above quote might not really be an adequate real-world analogy of what a pointer is.
I'd say a pointer is more like the coordinates of a house on the map, i.e., kind of a raw address instead of being given directions. For example, let's say there's a liquor store at 64°10′30″N 51°44′20″W. Then those coordinates would be like a pointer to liquor, the value you're trying to retrieve. Further, let's say that that liquor store is called “The House of Liquor”. If you'd take a taxi to get there, you wouldn't ask the driver to drop you at 64°10′30″N 51°44′20″W. Rather, you'd ask to be taken to “The House of Liquor”. In short, “The House of Liquor” is like a variable name, while the coordinates of that place would be equivalent to a pointer, wouldn't they?
The text was updated successfully, but these errors were encountered:
Loosely, it's the difference between being at a house and having the address of the house.
It's been a while, but I might have been trying to capture the expense / motion of the indirection, which I feel "direction" better captures. It feels like I'm in the car actually going to the house, which involves work; whereas address / location is just a static piece of information which doesn't necessarily involve resolution. Which, again, is true, the address by itself is useful (and can be used directly), but that's a more advanced topic.
Or maybe I just didn't think about it so much and was happy with the first thing that kinda sounded right.
In chapter 2, when introducing pointers, the book says:
Now, I'm by no means an experienced programmer and just started with Go two hours ago. I do have a little bit of C experience, though. And I think that the last sentence in the above quote might not really be an adequate real-world analogy of what a pointer is.
I'd say a pointer is more like the coordinates of a house on the map, i.e., kind of a raw address instead of being given directions. For example, let's say there's a liquor store at
64°10′30″N 51°44′20″W
. Then those coordinates would be like a pointer to liquor, the value you're trying to retrieve. Further, let's say that that liquor store is called “The House of Liquor”. If you'd take a taxi to get there, you wouldn't ask the driver to drop you at64°10′30″N 51°44′20″W
. Rather, you'd ask to be taken to “The House of Liquor”. In short, “The House of Liquor” is like a variable name, while the coordinates of that place would be equivalent to a pointer, wouldn't they?The text was updated successfully, but these errors were encountered: