clojurescript宏不能在clojurescript中写

clojurescript宏不能在clojurescript中写

本文介绍了为什么clojurescript宏不能在clojurescript中写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然clojure和clojurescript功能基本相同(除了明显的差异),宏不是。当我想要一个宏在clojurescript我必须写在clojure和需要它与require-macros。这是JavaScript的技术限制还是只是一个设计决定?为什么两者不能相同?

While clojure and clojurescript features are basically the same (apart from obvious differences), macros are not. When I want a macro in clojurescript I have to write it in clojure and require it with require-macros. Is that a technical limitation of javascript or just a design decision? Why can't both be the same?

推荐答案

从 by Stuart Sierra and Luker VanderHart,page 69:

From ClojureScript: Up and Running by Stuart Sierra and Luker VanderHart, page 69:

这意味着宏代码在Clojure世界中执行,而不是在浏览器中执行,所以它必须以Clojure的纯文本编写。

What that means is that macro code gets executed in Clojure world and not in the browser, so it must be written in plain Clojure.

这篇关于为什么clojurescript宏不能在clojurescript中写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 12:57