当我尝试gambit的gsi (4.6.6)时,当我在let中输入一些无效的东西时,我遇到了一个奇怪的情况。
按照正常的方式做,一切都和预期的一样。i andj是不可见的。
> (let ((i 4) (j 3)) (display (+ i j)) (newline))
7
> i
*** ERROR IN (console)@2.1 -- Unbound variable: i
1> j
*** ERROR IN (console)@3.1 -- Unbound variable: j但是,如果我在let块中搞砸了,i andj是可见的。几乎就像我仍然在let表单的作用域中一样。这是怎么回事?另外,看看提示符上的数字,例如>1> `2>等。看起来那里也有信息。如果是,那是什么?可能是与嵌套或错误模式相关的东西?
2> (let ((i 2) (j 3)) (display + i j) (newline))
*** ERROR IN (console)@4.20 -- Wrong number of arguments passed to procedure
(display '#<procedure #2 +> 2 3)
3> i
2
3> j
3这与clojure中的稍有不同。例如:
user=> (defn display [n] (print n))
#'user/one-arg-function
user=> (let [i 2 j 3] (display + i j) (println))
ArityException Wrong number of args (3) passed to: user$one-arg-function clojure.lang.AFn.throwArity (AFn.java:437)
user=> i
CompilerException java.lang.RuntimeException: Unable to resolve symbol: i in this context, compiling:(NO_SOURCE_PATH:0)
user=> j
CompilerException java.lang.RuntimeException: Unable to resolve symbol: j in this context, compiling:(NO_SOURCE_PATH:0) 发布于 2012-12-18 23:48:07
这是Gambit的交互式调试器的一个特性。
摘自手册:http://www.iro.umontreal.ca/~gambit/doc/gambit-c.html#Debugging
然后在评估停止的执行点的上下文中启动嵌套REPL。嵌套的REPL的继续和求值环境与求值停止的点相同。例如,当计算表达式‘(let ((y (- 1 1) (* (/ x y) 2))’时,会报告“被零除”错误,并且嵌套的REPL的延续是取结果并将其乘以2的延续。REPL的词法环境包括词法变量‘y’。这允许检查评估上下文(即,词汇和动态环境以及延续),这对于确定错误的确切位置和原因特别有用。
在您的示例中,嵌套的REPL开始于let内部,因此绑定了i和j。
https://stackoverflow.com/questions/13926060
复制相似问题