This is a question to get some information before thinking about a possible 
proposal regarding zero values.

*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?

Example:
type Pet struct {
 name string
 kind string
}
type Person struct {
 name    string
 age     int
 friends []Person
 pet     Pet
}


// Current Go
var person1 Person // { name: "", age: 0, friends: [], pet: <nil> }
var person2 *Person // <nil>


// Assuming the zero value of a pointer is a pointer to the zero value of 
what it points to, then:
var person1 Person // { name: "", age: 0, friends:[], pet: &{ name: "", 
kind: "" } }
var person2 *Person // &{ name: "", age: 0, friends:[], pet: &{ name: "", 
kind: "" } }

Thanks!

-- 
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/063deac8-f32f-4236-9f3d-ea8cae74ada5%40googlegroups.com.

Reply via email to