Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
(load-string s) 根据其文档:
“顺序读取和评估字符串中包含的一组表单”
为什么它在以下代码中不起作用?
(let [fun #(+ 1 2)] (load-string "(fun)"))
谢谢您的帮助!
您根本无法从加载字符串访问词法环境,因此即使这样也行不通:
(let [fun 12] (load-string "(+ 1 fun)"))
只有绑定值有效,请参见此处:
使用 clojure 的动态代码