From 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.
However, in MIT-scheme 10.1.10 on Debian buster 10, I do:
(environment-has-parent? (the-environment))
;Value: #t
(environment-parent (the-environment))
;Value: #f
These two results seem to contradict. (the-environment)
has a parent, but its parent is false
. What gives? I was expecting the second call to return some environment and print it, like ;Value: #[environment 12]
or something, but instead it returns a boolean.
Edit: as one commenter pointed out below #f
is an environment and we can get its bindings and everything. Of course, the bindings are not stored in the #f
object, but still, that is an incredibly strange and undocumented convention they are using.
In MIT Scheme 10.1.10, #f
is effectively treated as the top-level environment, and this is simply a convention that is undocumented in the manual.