On Friday, July 1, 2016 at 3:44:10 PM UTC+2, Martin Geisler wrote: > > On Fri, Jul 1, 2016 at 12:52 PM, Chad <send...@gmail.com <javascript:>> > wrote: > > However, that it's a valid point you raise (re strings) > > But that's exactly the reason for which, someone would probably ask > whether > > a string is a reference type or a value type. > > > > This could probably made clearer in the documentation. > > I keep seeing references (hah!) to this concept of a "reference type" > :-) However, I just tried searching the language spec and Effective Go > and there doesn't seem to be such a concept defined in those > documents.
I think it should. It is mentioned here however https://blog.golang.org/go-maps-in-action Without that, one of the first instinct of beginning programmers is often to create pointers to slices. I feel that, more clarifications about this area of the language would help a lot instead. This is also a terminology of PLT that exists in other languages but as usual, one has to be careful about the implementation false friends. > Effective Go talks about slices and maps having > "references" to some underlying data, but I don't think it says that > maps and slices themselves are "reference types". > > So my understanding is that there is no such concept in Go. Instead > there are structs and pointers -- maps and slices are builtin types, > implemented as small structs that points to larger pieces of data. > When you pass either to a function, you end up copying the struct -- > the normal value semantic we all know so well. Copying the struct is > fine since they're small: a slice is a pointer and two ints, I'm > unsure how a map looks like but I hope it's similarly sized. > > I'm very new to Go, so please let me know if I'm missing anything? > > -- > Martin Geisler > -- 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.