5

所以四处挖掘试图弄清楚如何在 Clojure 中执行 ADT,我遇到了旧的 clojure-contrib,它很好,只是它已被替换。好的,没什么大不了的,只需查看被替换的 clojure-contrib 的分解库目录,但是对于我的生活,我无法找到 defadt 在新的 clojure-contrib 分解库中迁移的位置。

那么它迁移到了哪里呢?

我一直在寻找http://dev.clojure.org/display/doc/Clojure+Contrib+Libraries但无法弄清楚。

如果你能把绳子递给我,让我alembic.still/distill把它插上,就可以加分。

4

1 回答 1

5

The usual style in Clojure isn't to define ADTs. I'd regard the defadt functionality as old / deprecated.

Instead, consider defining your data structures using regular Clojure maps or vectors.

Alternatively you could use deftype or defrecord if you want a named type which can be used for polymorphic dispatch using protocols. This is a flexible and fast way of getting ADT-like behaviour.

于 2014-02-26T04:42:09.417 回答