Zig API 设计理念与抽象 #68
jiacai2050
started this conversation in
General
Replies: 3 comments 1 reply
-
目前的字段完全公共很依赖于文档本身的说明,有趣的是现在zig官方文档中仍存在着不少 commit 根本不写注释说明或者非常简短,让人看得云里雾里 |
Beta Was this translation helpful? Give feedback.
1 reply
-
其实我认为或许可以在注释层面额外增加一层标记是否为私有,这样子可以让zls本身给出信息提示,但在语言实现时又没有额外的复杂性增加 |
Beta Was this translation helpful? Give feedback.
0 replies
-
个人认为,自己定个规则 ,比如私有的变量前置下划线就行了。以我在c#中的经验来看,c#有private关键字,但是大家写代码的时候,还是会把private的成员命名成'_xxx'这样,既然如此,何必多个private声明出来 ,变量名自包含不是更简单。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
这次讨论的话题来自 What is the Zig philosophy on APIs and abstraction? 这个 Reddit 帖子,讨论 Zig 的在 API 设计上的哲学、理念。一个有意思的点是 Zig 不支持私有的字段,全部都是 public 的。Andrew 在 Proposal: Private Fields #9909 这个 issue 里面讨论过原因,主要根据:
Beta Was this translation helpful? Give feedback.
All reactions