golang / tour

[mirror] A Tour of Go
BSD 3-Clause "New" or "Revised" License
1.55k stars 520 forks source link

tour: The phrase `The type *T is a pointer to a T value` was not intuitive for me. #1561

Open jcnars opened 11 months ago

jcnars commented 11 months ago

Context: https://go.dev/tour/moretypes/1

Change the title above to describe your issue and add your feedback here, including code if necessary

By:

The type *T is a pointer to a T value.

My mind constructed it to mean: *T is a pointer to a T value... When in fact &T is a pointer to a T.

The text following it explains stuff, but still the first reading didn't sit well. Maybe it's just me and you can ignore this.

jcnars commented 11 months ago

Ah !

I see where I got it mixed up.

The *T (as in *int) is simply a type that represents a pointer to base type T (int). There is also this *t which represents the value at address/pointer t.

This was beautifully explained in this video: https://youtu.be/sTFJtxJXkaY?si=K2OTwhlDLDpfU5Ro

I wonder if the tour.go.dev pointer page be slightly modified with this aha moment.