美文网首页
clojurescript 使用 clojure 开头ns 需要

clojurescript 使用 clojure 开头ns 需要

作者: onedam | 来源:发表于2022-04-17 16:59 被阅读0次
    • 在org.clojure/tools.reader 中有 2 套 代码 一套 cljs 一套clojure 用在clojurescript中的时候会替换掉 代码中出现引用 clojure.xxx 的 cljs.xxx
      在sci 项目中


      image.png

      如果用clojurescript来编译(cljurescript当前(2022年4月17日)还是在jvm上运行的,在运行过程中会加入 futures "cljs" )
      上面的clojure.tools.reader.reader-types :as r 会变成
      cljs.tools.reader.reader-types :as r

    image.png
    • CLJS-1692: Autoalias clojure.* to exisiting cljs.* namespaces if possible
    •     (defn clj-ns->cljs-ns
            "Given a symbol that starts with clojure as the first segment return the
             same symbol with the first segment replaced with cljs"
            [sym]
            (let [segs (string/split (clojure.core/name sym) #"\.")]
              (if (= "clojure" (first segs))
                (symbol (string/join "." (cons "cljs" (next segs))))
                sym)))
      
     (defn rewrite-cljs-aliases
         "Alias non-existing clojure.* namespaces to existing cljs.* namespaces if
          possible."
         [args]
         (map process-rewrite-form args))
    

    相关文章

      网友评论

          本文标题:clojurescript 使用 clojure 开头ns 需要

          本文链接:https://www.haomeiwen.com/subject/mfelertx.html