类型空列表的缺点不起作用

cons to empty list of type not working

我正在学习《编程语言:应用与解释》一书第 6 章 http://cs.brown.edu/courses/cs173/2012/book/From_Substitution_to_Environments.html

我已经应用了书中所述的修复程序,但缺点是没有将类型添加到源代码中引用的空列表中。 我认为这是 pass-by-value/pass-by-ref 的事情,关于如何设置 mt-env 当它没有作为参数传入时有什么线索吗?

#lang plai-typed

;; Binding types
(define-type Binding
  [bind (name : symbol) (val : number)])

;; some helper functions:
(define-type-alias Env (listof Binding))
(define mt-env empty)
(define extend-env cons)

;; testing function
(define (addBinding [b : Binding] [env : Env])
  (extend-env b env)
  )

(addBinding (bind 'x 5) mt-env) ;; returns (list (bind x 5))
(display mt-env) ;; returns empty list

下面是link上下文的完整代码,如果需要,interp函数的appC案例是我问题区域的具体位置,谢谢。 https://github.com/MickDuprez/plai/blob/master/Chapter%206/chapter-6.rkt

在重读了本章的最后部分几次之后,我认为这个问题没有简单的解决方案。 'change' 仅使修改后的解释器的行为与之前的 'substitution' 解释器相同,但突出了特殊测试用例的范围问题。

作者在下一部分“6.4 范围”中回避了这一点:

"The broken environment interpreter above implements what is known as dynamic scope."

我相信这会在以后的章节中得到解决,感谢您的阅读。