environment-parent 和 environment-has-parent 的矛盾结果?在 MIT 计划中
contradicting results for environment-parent and environment-has-parent? in MIT-scheme
来自the official MIT-scheme texinfo manual:
Environments are first-class objects in MIT/GNU Scheme. An
environment consists of some bindings and possibly a parent
environment, from which other bindings are inherited.
... some other info omitted ...
-- procedure: environment-has-parent? environment
Returns #t
if environment has a parent environment; otherwise
returns #f
.
-- procedure: environment-parent environment
Returns the parent environment of environment. It is an error if
environment has no parent.
但是,在 Debian buster 10 上的 MIT 方案 10.1.10 中,我这样做:
(environment-has-parent? (the-environment))
;Value: #t
(environment-parent (the-environment))
;Value: #f
这两个结果似乎是矛盾的。 (the-environment)
有 个父项,但其父项是 false
。是什么赋予了?我期待第二次调用 return 一些环境并打印它,比如 ;Value: #[environment 12]
之类的,但它 return 是一个布尔值。
编辑:正如一位评论者在下面指出的那样,#f
是一个环境,我们可以获得它的绑定和所有内容。当然,绑定未 存储 在 #f
对象 中,但仍然是一个令人难以置信的奇怪且未记录的约定使用。
在 MIT Scheme 10.1.10 中,#f
被有效地视为顶级环境,这只是一个约定,手册中没有记载。
来自the official MIT-scheme texinfo manual:
Environments are first-class objects in MIT/GNU Scheme. An environment consists of some bindings and possibly a parent environment, from which other bindings are inherited.
... some other info omitted ...
-- procedure: environment-has-parent? environment
Returns#t
if environment has a parent environment; otherwise returns#f
.-- procedure: environment-parent environment
Returns the parent environment of environment. It is an error if environment has no parent.
但是,在 Debian buster 10 上的 MIT 方案 10.1.10 中,我这样做:
(environment-has-parent? (the-environment))
;Value: #t
(environment-parent (the-environment))
;Value: #f
这两个结果似乎是矛盾的。 (the-environment)
有 个父项,但其父项是 false
。是什么赋予了?我期待第二次调用 return 一些环境并打印它,比如 ;Value: #[environment 12]
之类的,但它 return 是一个布尔值。
编辑:正如一位评论者在下面指出的那样,#f
是一个环境,我们可以获得它的绑定和所有内容。当然,绑定未 存储 在 #f
对象 中,但仍然是一个令人难以置信的奇怪且未记录的约定使用。
在 MIT Scheme 10.1.10 中,#f
被有效地视为顶级环境,这只是一个约定,手册中没有记载。