Most of the answers have been shared already. I'll add only the meaning: Basic variables associate names with the value of data, but pointer variables associate names with the location of data. In an array or slice the name and index serve similar purposes, where the 5 in m[5] is a kind of address ("sixth in m"), but pointer variables do this without needing the "in m" by expressing the address in terms of the whole of process memory.
Pointers let us work with dynamic storage. "f := make([]int, 32)" is a managed version of this, "k := &{Car}" is a plain one. Algorithms that manipulate storage areas (allocators, pools, garage collectors, etc.) are enabled by pointers, as are all algorithms that dynamically manage general references to data, such as trees, heaps, linked lists, and Knuth's algorithm X. In programming language terms, pointers let you decide if and when you want an Lvalue or an Rvalue; you can do everything via pointers but only some things via the values themselves. On Tue, Jan 1, 2019 at 11:20 AM Andy Balholm <andybalh...@gmail.com> wrote: > Some languages, like Java, don’t have explicit pointer types. But they do > it by making almost everything an implicit pointer. > > Andy > > On Jan 1, 2019, at 9:13 AM, Jan Mercl <0xj...@gmail.com> wrote: > > > On Tue, Jan 1, 2019 at 12:34 PM 伊藤和也 <kazya.ito.dr...@gmail.com> wrote: > > > What are the reasonable reasons to use pointers? Are pointers neseccary? > > Yes, they're necessary in non-trivial programs. Without pointers any > program can use only (named) variables declared in the program. Pointers > allow creating (anonymous) variables at run time accessed via the pointer. > Many useful data structures rely on variables dynamically allocated at run > time. > -- > > -j > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- *Michael T. jonesmichael.jo...@gmail.com <michael.jo...@gmail.com>* -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.