On Tue, Oct 31, 2017 at 5:33 PM, <oju...@gmail.com> wrote: > The internal layout Go uses to store an interface should not mess with the > expected behavior. > If interface is two separate fields, or just a pointer, or refers to a > bitmap stored on the Moon, I don't care. I shouldn't care.
And you don't have to care. This is not an implementation detail, it is a spec-detail. It is a consequence of a) Methods can be declared on any type, including pointers b) Methods can be called on any value of that type, including its zero value c) An interface is a type for "any type with the following sets of methods" Whether you represent an interface as one word, two words, zero words or one billion words is irrelevant, as long as you implement Go, you have to adhere to these rules and they imply the criticized behavior. Personally, I have a gripe with the fact that the FAQ justifies this behavior with an implementation detail, when really it's a consequence of the language. The rules a), b) and c) make individually total sense. It makes sense to be able to declare methods on pointers, as it is expected that methods can modify state from other imperative languages. It makes sense that methods can be called on zero values, because they should be a property of the type, not the value. It makes sense to have the notion of a method set as an interface. I sincerely hope Go 2 will have it fixed. > https://github.com/golang/go/issues/21538 has already been filed and there might be other issues amounting to the same thing. I think it is fair to say, that a) for Go1, this can't be changed either way and b) for Go2, the community is aware of the confusion. -- 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. For more options, visit https://groups.google.com/d/optout.