<bdo id='CyglU'></bdo><ul id='CyglU'></ul>
    1. <tfoot id='CyglU'></tfoot>

      <small id='CyglU'></small><noframes id='CyglU'>

    2. <legend id='CyglU'><style id='CyglU'><dir id='CyglU'><q id='CyglU'></q></dir></style></legend>
    3. <i id='CyglU'><tr id='CyglU'><dt id='CyglU'><q id='CyglU'><span id='CyglU'><b id='CyglU'><form id='CyglU'><ins id='CyglU'></ins><ul id='CyglU'></ul><sub id='CyglU'></sub></form><legend id='CyglU'></legend><bdo id='CyglU'><pre id='CyglU'><center id='CyglU'></center></pre></bdo></b><th id='CyglU'></th></span></q></dt></tr></i><div id='CyglU'><tfoot id='CyglU'></tfoot><dl id='CyglU'><fieldset id='CyglU'></fieldset></dl></div>

        为什么 Objective-C 使用 YES/NO 宏约定而不是 true/false?

        时间:2023-10-05
        <tfoot id='ytEeJ'></tfoot>

            <tbody id='ytEeJ'></tbody>

            <small id='ytEeJ'></small><noframes id='ytEeJ'>

                • <bdo id='ytEeJ'></bdo><ul id='ytEeJ'></ul>
                  <i id='ytEeJ'><tr id='ytEeJ'><dt id='ytEeJ'><q id='ytEeJ'><span id='ytEeJ'><b id='ytEeJ'><form id='ytEeJ'><ins id='ytEeJ'></ins><ul id='ytEeJ'></ul><sub id='ytEeJ'></sub></form><legend id='ytEeJ'></legend><bdo id='ytEeJ'><pre id='ytEeJ'><center id='ytEeJ'></center></pre></bdo></b><th id='ytEeJ'></th></span></q></dt></tr></i><div id='ytEeJ'><tfoot id='ytEeJ'></tfoot><dl id='ytEeJ'><fieldset id='ytEeJ'></fieldset></dl></div>
                  <legend id='ytEeJ'><style id='ytEeJ'><dir id='ytEeJ'><q id='ytEeJ'></q></dir></style></legend>

                • 本文介绍了为什么 Objective-C 使用 YES/NO 宏约定而不是 true/false?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  大多数语言使用 true/false 关键字作为布尔值.我发现即使 Smalltalk 也在使用 true/false.我知道 Objective-C 只是借用 Smalltalk 的概念,而不是语言本身,但我很好奇它为什么使用 YES/NO 而不是更广泛使用的 true/false.有什么历史原因吗?

                  Most languages use the true/false keywords for boolean values. I found that even Smalltalk is using true/false. I know Objective-C is just borrowing concepts from Smalltalk, not the language itself, but I'm curious why it's using YES/NO instead of the more widely-used true/false. Is there any historical reason?

                  推荐答案

                  Objective-C 被设计为(并且仍然是)C 的严格超集.创建者非常努力地确保他们不会破坏与 C 的兼容性以任何方式.他们还试图让他们的修改更加明显,以便很容易分辨出代码的哪些部分使用了 Objective-C,哪些部分使用了普通 C.例如,用于表示 NSStrings 的 @而不仅仅是使用引号.这允许纯 C 字符串与新字符串共存.

                  Objective-C was designed to be (and still is) a strict superset of C. The creators worked very hard to ensure that they did not break compatibility with C in any way. They also tried to make their modifications somewhat obvious so that it would be easy to tell which parts of the code use Objective-C and which parts use plain C. Case in point, the @ used to denote NSStrings rather than just using quotes. This allows plain C strings to coexist with the new ones.

                  C 已经有一个非正式的 TRUE/FALSE 宏系统.我怀疑 Objective-C 的设计者选择 YES/NO 宏是为了避免冲突,并明确代码实际上是 Objective-C.还要注意空"对象的 nil 用法,而不是仅仅修改旧 NULL 的行为.

                  C already had an informal system of TRUE/FALSE macros. I suspect the designers of Objective-C chose the YES/NO macros to avoid conflict and to make it obvious that the code is actually Objective-C. Notice also the usage nil for the 'empty' object rather than just modifying the behavior of good old NULL.

                  这篇关于为什么 Objective-C 使用 YES/NO 宏约定而不是 true/false?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    <tfoot id='1PAs4'></tfoot>

                      <bdo id='1PAs4'></bdo><ul id='1PAs4'></ul>

                        1. <small id='1PAs4'></small><noframes id='1PAs4'>

                        2. <legend id='1PAs4'><style id='1PAs4'><dir id='1PAs4'><q id='1PAs4'></q></dir></style></legend>
                            <tbody id='1PAs4'></tbody>
                          <i id='1PAs4'><tr id='1PAs4'><dt id='1PAs4'><q id='1PAs4'><span id='1PAs4'><b id='1PAs4'><form id='1PAs4'><ins id='1PAs4'></ins><ul id='1PAs4'></ul><sub id='1PAs4'></sub></form><legend id='1PAs4'></legend><bdo id='1PAs4'><pre id='1PAs4'><center id='1PAs4'></center></pre></bdo></b><th id='1PAs4'></th></span></q></dt></tr></i><div id='1PAs4'><tfoot id='1PAs4'></tfoot><dl id='1PAs4'><fieldset id='1PAs4'></fieldset></dl></div>