News for hackers. Stuff that matters.
Re:Multiple nil types in Go. by _ak on Tuesday January 07, 2014 @01:59AM (#7016078)
Re:Multiple nil types in Go. by cgearhart on Tuesday January 07, 2014 @08:54AM (#7017266)
`make` allocates and initializes `a`, setting it to nil effectively uninitializes the variable. See below, where I declare `c`, but don't initialize it. From the Golang spec, http://golang.org/ref/spec#Map_types, the value of an uninitialized map is nil.

http://play.golang.org/p/J46-8OEWYS

Re:Multiple nil types in Go. by _ak on Tuesday January 07, 2014 @02:33PM (#7019316)
Don't tell me, I merely added one line of code to show that more information than the interface{} being nil is kept.
Re:Multiple nil types in Go. by eonil on Tuesday January 07, 2014 @02:10AM (#7016104)
This is even more interesting.
Re:Multiple nil types in Go. by LocalMan on Tuesday January 07, 2014 @07:47AM (#7016958)
In Go, nil is a value, not a type. Assigning 'nil' to an interface only assigns the value, not the type. An interface has both a value and a type at runtime, but is "nil" only if both the value and the type are nil.
Re:Multiple nil types in Go. by eonil on Tuesday January 07, 2014 @11:22AM (#7018069)
It's really hard to think the term nil is a value.

IMO, this is a bug in language design. If it's truly a value, I think they should choose a different term rather then `nil` as like they choose `panic/recover` instead of `throw/catch` because they're semantically different.

And also, I really don't know how should I detect nil reliably for an interface type.

[deleted]
Re:Multiple nil types in Go. by Xlab on Tuesday January 07, 2014 @06:10AM (#7016644)
Oh I think I found what happens, see http://golang.org/doc/faq#nil_error