SICP 打算如何在没有替代 (else) 部分的情况下使用 (if) 表格?

How does SICP intend the (if) forms without their alternative (else) part to work?

Exercise 1.22 of SICP 包含以下程序:

(define (start-prime-test n start-time)
  (if (prime? n)
      (report-prime (- (runtime) start-time))))

在我看来,if 表单没有替代分支。我只能看到if (test) (consequent)。 SICP在哪里引入这种形式? ifSection 1.1.6 but I see nowhere in that section that covers "if without else" cases. It is possible that I could guess the intended behavior from the definition of cond in that same section, but said section has a footnote中引入,可见两者不同。那么我怎么知道 SICP 打算如何使用这种 if 表格呢?

查了下索引,发现有两个地方定义了:4.1节的Footnote 29 in Section 3.3 and Footnote 10。引用两者:

Observe that the if expression in this procedure has no < alternative > expression. Such a ``one-armed if statement'' is used to decide whether to do something, rather than to select between two expressions. An if expression returns an unspecified value if the predicate is false and there is no < alternative >.

The value of an if expression when the predicate is false and there is no alternative is unspecified in Scheme; we have chosen here [in The Metacircular Evaluator] to make it false. We will support the use of the variables true and false in expressions to be evaluated by binding them in the global environment. See section 4.1.4.

我承认在查阅 Stack Overflow 之前我应该​​考虑查阅索引。显然,互联网已经腐蚀了我的大脑。但是,我希望这个问题有比我在这里给出的更好的答案。 “在你需要它之​​后定义了两章”,即使是正确的,也不是很愉快。

好的一面是,codybartfast 的评论正确地指出了您不需要理解练习 1.22 中描述的过程来解决问题。事实上,我自己解决了这个问题,很明显我想得太多了。不到五行就可以解决。此外,还指出,虽然它的前几个词恰好符合 Scheme 的标准,但上面的第二个引用主要是在谈论第 4 章中正在构建的实现,而不是任何预期使用或前面几章就明白了。