评论者:aralo
因此,CLJ工单中的问题在下面模拟/显示为CLJS
`
(enable-console-print!)
(defn self-call-test
[n]
(prn "inner")
(when (pos? n)
(self-call-test (dec n))))
(let [orig self-call-test]
(set! self-call-test
(fn outer [n]
(pr "outer")
(orig n))))
(self-call-test 2)
(def self-call-test2
(fn self-call-test2
[n]
(prn "inner")
(when (pos? n)
(self-call-test2 (dec n)))))
(let [orig self-call-test2]
(set! self-call-test2
(fn outer [n]
(pr "outer")
(orig n))))
(self-call-test2 2)
`
在没有任何优化时输出
`
"outer"
"inner"
"outer"
"inner"
"outer"
"inner"
"outer"
"inner"
"inner"
"inner"
`
因此:这似乎也会破坏当前的行为,然而,上述高级优化给出的是
"outer" "inner" "inner" "inner"
对两者都适用。考虑到这一点,在高级构建期间不更改行为似乎更好,以避免用户难以追踪的生产缺陷。即使这与Clojure行为略有不同。有什么想法吗?