我很好奇Scheme中define
的返回值。所以我在 Racket 中写了以下几行
#lang r5rs
(display (define a 3))
得到错误
define: not allowed in an expression context in: (define a 3)
我有两个问题:
- 是不是说
define
没有返回值? - 根据 R5RS,
define
不是表达式。这是一个程序结构。是不是只有表达式有返回值,其他形式没有?
最佳答案
"If a tree falls in a forest and no one is around to hear it, does it make a sound?"
在可以有意义地获得返回值的任何上下文中使用 define
都是无效的。所以它是否有返回值是没有意义的;你永远无法观察到它。
关于lisp - Scheme中 `define`的返回值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18799032/