Skip to content

Different empty interfaces are mutually incompatible (under 6g) #74

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

Closed
gopherbot opened this issue Nov 12, 2009 · 6 comments
Closed

Different empty interfaces are mutually incompatible (under 6g) #74

gopherbot opened this issue Nov 12, 2009 · 6 comments

Comments

@gopherbot
Copy link
Contributor

by punya.biswal:

What steps will reproduce the problem?

1. Try to create a heap with an underlying vector. (See attached source for 
details).

What is the expected output? What do you see instead?

It doesn't compile because *vector.Vector isn't heap.Interface (in 
particular, vector.Vector has Push(x vector.Element) and heap.Interface 
wants Push(x interface { }). This is odd because vector.Element is itself 
an empty interface.

What is your $GOOS?  $GOARCH?
GOOS=linux
GOARCH=amd64

Which revision are you sync'ed to?  (hg log -l 1)

3975:b51f...
Please provide any additional information below.

Attachments:

  1. element.go (236 bytes)
@rsc
Copy link
Contributor

rsc commented Nov 12, 2009

Comment 1:

The central issue here is that
func Push(vector.Element)
func Push(interface{})
are different types according to the language specification.
Similarly, if you had
type T int
then you could not use a method Add(T) to satisfy Add(int):
they're different types, which can be useful but is certainly
different from, say, C or C++.
The best answer to this might be to replace vector.Element
with interface{}.

Status changed to Accepted.

@gopherbot
Copy link
Contributor Author

Comment 2 by punya.biswal:

Just to make sure that I understand you correctly: is the recommended way to accomplish 
what I want to wrap vector.Vector in my own type and implement a bunch of pass-through 
methods in addition to the one thing I want to change?

@griesemer
Copy link
Contributor

Comment 3:

Owner changed to g...@golang.org.

@griesemer
Copy link
Contributor

Comment 4:

This issue was closed by revision 23843fa.

Status changed to Fixed.

Merged into issue #-.

@griesemer
Copy link
Contributor

Comment 5:

Your attached source now compiles w/o problems. Please send e-mail to golang-nuts for
questions about how 
to use it. Thanks.

@gopherbot
Copy link
Contributor Author

Comment 6 by punya.biswal:

Thanks for the speedy fix!

minux pushed a commit to minux/goios that referenced this issue Feb 27, 2015
Fixes golang#74

I have no idea why this is implemented in asm. If the compiler cannot do as good a job (and inline) then we should all just give up now.
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants