In.not: Non-aims(目标之外)
The rules are not intended to be minimal or orthogonal. In particular, general rules can be simple, but unenforceable. Also, it is often hard to understand the implications of a general rule. More specialized rules are often easier to understand and to enforce, but without general rules, they would just be a long list of special cases. We provide rules aimed at helping novices as well as rules supporting expert use. Some rules can be completely enforced, but others are based on heuristics.
这些规则不以最小化和正交为目的。通常,普遍的规则可以简单,但不会强制。同时,理解普遍规则的含义一般也比较困难。更加特殊的规则一般更容易理解和执行。但如果没有普遍规则,规则只能是一长串特殊情况的列举。我们提示规则时即希望帮助初学者,又支持专家用途。有些规则可以完全强制执行,有些则基于启发和引导。
These rules are not meant to be read serially, like a book. You can browse through them using the links. However, their main intended use is to be targets for tools. That is, a tool looks for violations and the tool returns links to violated rules. The rules then provide reasons, examples of potential consequences of the violation, and suggested remedies.
这些规则没有要求像书一样从前往后阅读。你可以使用链接通览它们。然而,最被期待的用法是作为工具使用。也就是说,用于检查规则违反和获取被违反规则的链接的工具。这些规则可以提供原因,违反的潜在后果示例和建议的改善措施。
These guidelines are not intended to be a substitute for a tutorial treatment of C++. If you need a tutorial for some given level of experience, see the references.
这些准则没有意图成为C++入门培训的代替者。如果你需要某种层次的辅导,请参照参考资料。
This is not a guide on how to convert old C++ code to more modern code. It is meant to articulate ideas for new code in a concrete fashion. However, see the modernization section for some possible approaches to modernizing/rejuvenating/upgrading. Importantly, the rules support gradual adoption: It is typically infeasible to completely convert a large code base all at once.
这也不是一个介绍如何将旧C++代码转换为更新式的代码的指南。它是关于以具体方式生成新代码的明确想法的。然而,现代化的部分可以看做是通往现代化/年轻化/升级的可能方式。重要的是,这些规则支持循序渐进式的运用:它通常不适合一次彻底转换大量代码时使用。
These guidelines are not meant to be complete or exact in every language-technical detail. For the final word on language definition issues, including every exception to general rules and every feature, see the ISO C++ standard.
这些指南也没有意图在每个语言技术细节做到完全和彻底。关于语言定义方面的最终表达,包含普遍规则的每个例外、每个功能等,请参照ISO C++标准。
The rules are not intended to force you to write in an impoverished subset of C++. They are emphatically not meant to define a, say, Java-like subset of C++. They are not meant to define a single "one true C++" language. We value expressiveness and uncompromised performance.
这些规则没有意图强制你在C++的贫乏子集内写代码。特别是没有意图定义一个类Java的C++子集。它们也没有意图定义一个独立的“真正的C++”语言。我们重视表现力的同时不在性能上妥协。
The rules are not value-neutral. They are meant to make code simpler and more correct/safer than most existing C++ code, without loss of performance. They are meant to inhibit perfectly valid C++ code that correlates with errors, spurious complexity, and poor performance.
这些规则是有倾向性的。它们试图使代码比多数已经存在的C++代码更简单而且更正确和安全。它们希望可以禁止完全合法但是会带来错误,不必要的复杂性和不良性能的C++代码。
The rules are not precise to the point where a person (or machine) can follow them blindly. The enforcement parts try to be that, but we would rather leave a rule or a definition a bit vague and open to interpretation than specify something precisely and wrong. Sometimes, precision comes only with time and experience. Design is not (yet) a form of Math.
这些规则没有精确到一个人(或机器)可以盲目地遵从的程度。执行的部分努力做到这一点,但是我们更愿意让规则或者定义稍微含糊一些以便解释而不是过度精确的定义却导致错误。有时准确只能源自积累和经验。设计还不是数学的一种形式。
The rules are not perfect. A rule can do harm by prohibiting something that is useful in a given situation. A rule can do harm by failing to prohibit something that enables a serious error in a given situation. A rule can do a lot of harm by being vague, ambiguous, unenforceable, or by enabling every solution to a problem. It is impossible to completely meet the "do no harm" criteria. Instead, our aim is the less ambitious: "Do the most good for most programmers"; if you cannot live with a rule, object to it, ignore it, but don't water it down until it becomes meaningless. Also, suggest an improvement.
规则不是完美的。在某些特性场合,它可能会因为阻止某些有用的事情发生变得有害。在某些特定场合,规则可能因为没能阻止产生一系列错误的产生会变得有害。规则可能由于含糊,模棱两可,不可行或者产生让每个解决方案发生问题而产生很多危害。不可能存在完全无害的准则。相反,我们的目标不那么雄心勃勃:“为大多数程序做尽量好的事情”;如果你不能接纳某条规则,你可以反对它,忽略它,但不要打折扣地执行直至它变得毫无意义。你也可以提出改善建议。
本文分享自微信公众号 - 面向对象思考(OOThinkingDalian)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。