On Fri, Feb 14, 2020, at 09:16, kloste...@gmail.com 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/a34818b1-0e3f-4712-ade4-d5e4f921279b%40www.fastmail.com.

Reply via email to