gyuho / learn

learn
https://gyuho.dev
Other
1.32k stars 152 forks source link

channel is syntactically pointer #50

Closed gyuho closed 9 years ago

gyuho commented 9 years ago

https://golang.org/doc/faq#references

Why are maps, slices, and channels references while arrays are values?

There's a lot of history on that topic. Early on, maps and channels were syntactically pointers and it was impossible to declare or use a non-pointer instance. Also, we struggled with how arrays should work. Eventually we decided that the strict separation of pointers and values made the language harder to use. Changing these types to act as references to the associated, shared data structures resolved these issues. This change added some regrettable complexity to the language but had a large effect on usability: Go became a more productive, comfortable language when it was introduced.