1
我正在使用multimethods来解析命令行命令及其参数。如何在clojure中设置和获取多方法元数据?
(defmulti run (fn [command args] command))
(defmethod run :default
[& _]
...)
^{:args "[command]"}
(defmethod run "help"
[_ & [args]]
"Display command list or help for a given command"
...)
^{:args ""}
(defmethod run "version"
[_ & [args]]
"Print program's version"
...)
(defn -main
[& args]
(run (first args)
(next args)))
当我试图访问元数据,具体的方法,Clojure的返回nil
:
(meta ((methods run) "help"))