Hacker News new | past | comments | ask | show | jobs | submit login

> The interface tuple returned by a() is ([]int, nil), comparing this to nil, which is a (nil,nil) returns false(!)

It's certainly a subtlety that can bite you, but I'd say that in this form it is arguably more consistent: assigning a type to an interface and having that be nil is not the same as assigning nil to an interface - those two variables are not equal and should be treated as such.




How is this more consistent? This can produce nil pointer dereferences.


> those two variables are not equal and should be treated as such.

In that sense. Don't get me wrong: I'm not saying it fixes other problems with nill pointers, and yes, it introduces an extra possibility for dereference problems. Just like you're allowed to call methods on nill pointers if it's a nill pointer to a type that has these methods.

https://groups.google.com/forum/?fromgroups=#!searchin/golan...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: