显然,我可以去 Clojure 的 Github 页面或查看我的 maven 存储库,这不是字面上获取源代码的问题。
我想以编程方式获取命名空间中定义的所有顶级表单。就像是
(get-top-level-forms-of 'clojure.zip)
=>
['(ns ^{:doc "Functional hierarchical zipper, with navigation, editing,
and enumeration. See Huet"
:author "Rich Hickey"}
clojure.zip
(:refer-clojure :exclude (replace remove next)))
'(defn zipper
"Creates a new zipper structure.
branch? is a fn that, given a node, returns true if can have
children, even if it currently doesn't.
children is a fn that, given a branch node, returns a seq of its
children.
make-node is a fn that, given an existing node and a seq of
children, returns a new branch node with the supplied children.
root is the root node."
{:added "1.0"}
[branch? children make-node root]
^{:zip/branch? branch? :zip/children children :zip/make-node make-node}
[root nil])
'(defn seq-zip
"Returns a zipper for nested sequences, given a root sequence"
{:added "1.0"}
[root]
(zipper seq?
identity
.....__ALL_THE_REST_OF_THE_FORMS_IN_clojure.zip_....]
基本上,只是按照定义的顺序获取命名空间中所有表单的有序序列。这可能吗?