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

书中go对象模型内容缺失?? #1

Open
lhprojects opened this issue Jul 12, 2013 · 4 comments
Open

书中go对象模型内容缺失?? #1

lhprojects opened this issue Jul 12, 2013 · 4 comments

Comments

@lhprojects
Copy link

我只是好奇go的interface是如何实现的/是一个胖指针?还是类似c++在对象中对应每个父类放置一个vptr?blah,blah.似乎在目录中根本找不到只写方面的内容.书中go对象模型内容缺失?

@tiancaiamao
Copy link
Owner

interface着不多就是一个胖指针。它存了两个域:
一个域是指向对象数据的指针,另一个域是指向类型信息的结构体的指针。
类型信息结构体里面存放的东西就很多了,包含了方法表等等信息,不过没有继承之类的东西,因为go中没有c++那种继承的。
c++中的虚函数表指针,链出去只是函数相关的信息。而go的interface的这个指针出去是指向一个类型信息结构体,不仅仅是函数相关的信息,更加丰富。所以在反射方面做得很强大,当然,重量级一些,性能也就低一些。
近段时间忙啊,都没时间写,后面会写到interface的......plus,我是反面向对象主义者。即使写了也不叫go的对象模型,估计叫类型系统之类的 : -)

@lhprojects
Copy link
Author

well.期待.

tiancaiamao pushed a commit that referenced this issue May 12, 2014
@ty359
Copy link

ty359 commented Nov 24, 2019

原作者现在还有兴趣完成这一部分吗。其他部分质量都很高,这一部分有内容缺失太可惜了。

@tiancaiamao
Copy link
Owner

原作者现在还有兴趣完成这一部分吗。其他部分质量都很高,这一部分有内容缺失太可惜了。

2020 年我考虑一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants