Thanks for the response! and the pointer itself would lose the nice property of being a zeroed chunk > of memory (it wouldn't be a zero value). >
I see it is a nice property, but I'd say only for people writing the compiler. I adventure to say that people using the language won't care too much about this property. Having a useful zero-value (in this case, an initialized pointer), like we have with strings for example, would be a very nice property for language users El viernes, 14 de febrero de 2020, 15:01:52 (UTC), Sam Whited escribió: > > On Fri, Feb 14, 2020, at 09:16, klos...@gmail.com <javascript:> wrote: > > *Could you please let me know the reasons why the zero value of a > > pointer is `nil` instead of a pointer to the zero value of what it > > points to?* > > > > Is it because of performance/memory? Simplicity in the runtime? > > The zero value is a zeroed chunk of memory with the given type. If > the zero value of the pointer were a pointer to something else, that > something else would have to be allocated and pointed too and the > pointer itself would lose the nice property of being a zeroed chunk > of memory (it wouldn't be a zero value). > > —Sam > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d57968d2-d93c-4fb0-9086-adfe2a2253d5%40googlegroups.com.