Resolve函数在ClojureScript中抛出一个错误,但不是Clojure [英] Resolve function throws an error in ClojureScript but not Clojure

查看:134
本文介绍了Resolve函数在ClojureScript中抛出一个错误,但不是Clojure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下程序按照我在Clojure中的预期工作,但在ClojureScript中抛出一个错误。我想知道这是否是一个错误或功能根本不是在ClojureScript中可用,或者如果我需要重新思考我试图这样做的方式。非常感谢您的帮助。

The following program works as I expected in Clojure, but throws an error in ClojureScript. I'm wondering if this is a bug or the feature simply isn't available in ClojureScript or if I need to rethink the way I'm attempting to do this instead. Thanks a lot for the help in advance.

; Clojure...
(defn foo [x] x)
(defn foobee [x] (str (foo x) "bee"))

(println
  ((resolve (symbol (str "foo" "bee"))) "bizzee"))

;=> bizzeebee

; ClojureScript...
(defn foo [x] x)
(defn foobee [x] (str (foo x) "bee"))

(.log js/console
  ((resolve (symbol (str "foo" "bee"))) "bizzee"))

;=> Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol


<在ClojureScript中不存在

=
事实上,ClojureScript没有Vars。

resolve doesn't exist in ClojureScript. In fact, ClojureScript does not have Vars.

调用一个名称是动态构造的函数可以通过各种hack(例如使用 aget 与命名空间对象),但是保证打破与高级编译,除非所有相关的符号导出。此外,目前没有人享受官方支持,即使有更宽松的编辑设置。

Calling a function whose name is constructed dynamically is possible through various hacks (like using aget with the namespace object), which are however guaranteed to break with advanced compilation unless all the relevant symbols are exported. Also, currently none enjoy official support even with the more permissive compilation settings.

这篇关于Resolve函数在ClojureScript中抛出一个错误,但不是Clojure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆