-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spec: document interface satisfaction more explicitly #5570
Labels
Milestone
Comments
IMO, the first three sentences at the link do define both exactly and completely (together -> clearly) the requirements: """ An interface type specifies a method set called its interface. A variable of interface type can store a value of any type with a method set that is any superset of the interface. Such a type is said to implement the interface. """ |
The section on method sets describes that the inclusion criteria is only related to methods, but doesn't say what it is exactly. The compilers use the rules for function identity for interface matching. You could probably refer to the type identity section, but extending it to methods or members of method sets might be confusing. Methods don't exist as types in the language, and methods and members of method sets have different identity rules. Example: method identity: func (f Foo) Bar(fb FooBar) == func (b Foo) Bar(bf FooBar) func (f Foo) Bar(fb FooBar) != func (b FooBar) Bar(bf Foo) member of method set identity: func (f Foo) Bar(fb FooBar) == func (b FooBar) Bar(bf FooBar) |
The Go 1.18 spec has now a section on what it means to implement an interface (see the end of the section on Interface types). Closing. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: