Skip to content
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

Open
dsymonds opened this issue May 28, 2013 · 12 comments

Comments

@dsymonds
Copy link
Member

commented May 28, 2013

http://golang.org/ref/spec#Interface_types does not clearly spell out the requirements
for a type to implement an interface. It should.
@cznic

This comment has been minimized.

Copy link
Contributor

commented May 28, 2013

Comment 1:

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. 
"""
@dsymonds

This comment has been minimized.

Copy link
Member Author

commented May 28, 2013

Comment 2:

It does not define the set inclusion criteria. One might (incorrectly)
guess assignability or callability. Or might guess that parameter names
must match too.
@DanielMorsing

This comment has been minimized.

Copy link
Contributor

commented May 28, 2013

Comment 3:

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)
@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 30, 2013

Comment 4:

Labels changed: added go1.2.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2013

Comment 6:

Labels changed: added go1.2maybe, removed go1.2.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 25, 2013

Comment 7:

Labels changed: added go1.3, removed go1.2maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 8:

Labels changed: added release-go1.3.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 9:

Labels changed: removed go1.3.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 10:

Labels changed: added repo-main.

@rsc

This comment has been minimized.

Copy link
Contributor

commented May 27, 2014

Comment 11:

Labels changed: added release-go1.4, removed release-go1.3.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 28, 2014

Comment 12:

Labels changed: added release-go1.4maybe, removed release-go1.4.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2014

Comment 13:

Labels changed: added release-go1.5, removed release-go1.4maybe.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014

@bradfitz bradfitz removed the release-go1.5 label Dec 16, 2014

@rsc rsc modified the milestones: Unplanned, Go1.5 Jul 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.