allow defprotocolpath to be defined with no params argument for consistency with declarepath
This commit is contained in:
parent
b16dbdfdd2
commit
8293f68696
2 changed files with 80 additions and 78 deletions
|
|
@ -2,6 +2,7 @@
|
|||
* ALL on maps auto-coerces MapEntry to vector, enabling smoother transformation of map keys
|
||||
* declarepath can now be parameterized
|
||||
* Added params-reset which calls its path with the params index reset to 0. This enables recursive parameterized paths
|
||||
* Added convenience syntax for defprotocolpath with no params, e.g. (defprotocolpath foo)
|
||||
|
||||
## 0.9.2
|
||||
* Added VOID selector which navigates nowhere
|
||||
|
|
|
|||
|
|
@ -205,7 +205,10 @@
|
|||
(defn- protpath-sym [name]
|
||||
(-> name (str "-prot") symbol))
|
||||
|
||||
(defmacro defprotocolpath [name params]
|
||||
(defmacro defprotocolpath
|
||||
([name]
|
||||
`(defprotocolpath ~name []))
|
||||
([name params]
|
||||
(let [prot-name (protpath-sym name)
|
||||
m (-> name (str "-retrieve") symbol)
|
||||
num-params (count params)
|
||||
|
|
@ -245,14 +248,18 @@
|
|||
)))
|
||||
~num-params
|
||||
)
|
||||
)))))
|
||||
))))))
|
||||
|
||||
|
||||
(defn declared-name [name]
|
||||
(symbol (str name "-declared")))
|
||||
|
||||
(defn- declarepath* [name num-params]
|
||||
(let [declared (declared-name name)
|
||||
(defmacro declarepath
|
||||
([name]
|
||||
`(declarepath ~name []))
|
||||
([name params]
|
||||
(let [num-params (count params)
|
||||
declared (declared-name name)
|
||||
rargs [(gensym "params") (gensym "pidx") (gensym "vals")
|
||||
(gensym "structure") (gensym "next-fn")]]
|
||||
`(do
|
||||
|
|
@ -283,13 +290,7 @@
|
|||
)))
|
||||
~num-params
|
||||
)
|
||||
)))))
|
||||
|
||||
|
||||
(defmacro declarepath
|
||||
([name] (declarepath* name 0))
|
||||
([name params]
|
||||
(declarepath* name (count params))))
|
||||
))))))
|
||||
|
||||
(defmacro providepath [name apath]
|
||||
`(let [comped# (comp-paths* ~apath)
|
||||
|
|
|
|||
Loading…
Reference in a new issue