问题描述
defstruct
- 它似乎是设计的。现在可能是,这实际上是Clojure语言的一个弃用的部分,ClojureScript的设计师只是希望大家都移动。 (但这是我的猜测)。
defstruct
is not supported in ClojureScript - it would appear to be by design. Now it may be that this is effectively a deprecated part of the Clojure language, and the designers of ClojureScript were just hoping everyone had moved on. (But this is my speculation).
我的问题是: ClojureScript背后的推理不需要Clojure的defstruct?
推荐答案
defstruct 是在语言中有效地弃用,赞成
defrecord
。我们应该继续(基于JVM的)Clojure,所以我希望Clojurescript是一样的。查看以下内容:
defstruct
is effectively deprecated in the language, in favor of defrecord
. We are supposed to move on in (JVM-based) Clojure, so I would expect Clojurescript to be the same. See the following:
:注意:现在,记录可以更好地为StructMaps提供服务。
Clojure: data structures: "Note: Most uses of StructMaps would now be better served by records."
我应该在哪里在clojure中使用defrecord?对 defrecord
的优点(和缺点)进行了很好的讨论,尽管他不是,主要是与 defstruct
比较。
Alex Miller's answer to "Where should I use defrecord in clojure?" has a nice discussion of advantages (and disadvantages) of defrecord
, although he's not, primarily, comparing it with defstruct
.
这篇关于ClojureScript背后的原因是什么,不需要Clojure的defstruct?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!