Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 2: Description of what a pointer is. #62

Open
msiism opened this issue Dec 13, 2019 · 1 comment
Open

Chapter 2: Description of what a pointer is. #62

msiism opened this issue Dec 13, 2019 · 1 comment

Comments

@msiism
Copy link

msiism commented Dec 13, 2019

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?

@karlseguin
Copy link
Owner

Yes, I could have said

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants