clojure.lang真的只是实现细节吗?

在Clojure中,一些任务(例如实例化
PersistentQueue或使用deftype实现与clojure.core函数兼容的自定义数据类型)需要了解
clojure.lang中的类和/或接口.

但是,根据clojure.lang/package.html

The only class considered part of the public API is 07003. All other classes should be considered implementation details.

这些陈述是不正确还是过时?如果是这样,是否有计划在将来纠正它们?如果没有,是否有更优选的方式来执行上述任务,或者在惯用的Clojure代码中根本不应该完成它们?

最佳答案 亚历克斯米勒过去有
commented这个(虽然整个线程值得一读):

I’d say there is a range of “public”-ness to the internals of Clojure.

  • The new Clojure API (clojure.java.api.Clojure) is an official public API for external callers of Clojure. This API basically consists of ways to resolve vars and invoke functions.
  • For Clojure users in Clojure, pretty much any var that’s public and has a docstring, and shows up in the api docs can be considered public API.
  • Clojure vars that are private or have no docstring (such that the var is omitted from public api docs) are likely places to tread very carefully.
  • The Clojure internal Java interfaces [clojure.lang] are certainly intended to allow library builders to create useful stuff that plays in the Clojure world. I do not know that anyone has ever said that they are “public”, but I certainly think that any change to a core interface likely to break external users would be considered very carefully.
  • The Clojure internal Java classes [clojure.lang] should in most cases be considered private and subject to change without notice. There are grey areas even there.

In general, we do not place a high value on encapsulation or hiding internals. In most cases, the internals are left available if they might be useful to an advanced user doing interesting things, with the caveat that the weirder things you do, the more likely you are to be accidentally broken in a future release.

点赞