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

ch6-06 译注 get it wrong #65

Open
AntonioSun opened this issue Mar 25, 2022 · 2 comments
Open

ch6-06 译注 get it wrong #65

AntonioSun opened this issue Mar 25, 2022 · 2 comments

Comments

@AntonioSun
Copy link

AntonioSun commented Mar 25, 2022

当然,我们也可以把IntSet定义为一个slice类型,但这样我们就需要把代码中所有方法里用到的s.words用*s替换掉了:

type IntSet []uint64

尽管这个版本的IntSet在本质上是一样的,但它也允许其它包中可以直接读取并编辑这个slice。换句话说,相对于*s这个表达式会出现在所有的包中,s.words只需要在定义IntSet的包中出现(译注:所以还是推荐后者吧的意思)。

Here is the original text:

Although this version of IntSet would be ess ent ial ly equivalent, it wou ld allow clients from
ot her packages to read and modif y the slice direc tly. Put another way, where as the expression
*s could be used in any package, s.words may appear only in the package that defines
IntSet.

Note the two key works, "could be used" and "may appear only", it emphasizes that the later is too relaxed that the en-capsulized info is leaked out and could be directly accessed anywhere.

Thus, it is not "还是推荐后者吧" but just the opposite.

@AntonioSun
Copy link
Author

Thus, it is not "还是推荐后者吧" but just the opposite.

Refer to

封装提供了...优点。首先,因为调用方不能直接修改对象的变量值,其只需要关注少量的语句并且只要弄懂少量变量的可能的值即可。

@ganggangxiao
Copy link

ganggangxiao commented Mar 27, 2022 via email

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

2 participants