Details
-
Type:
Enhancement
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Approval:Ok
Description
if we have a pattern matching macro like, for example, a cond-m that does something like
(cond-m some-value
some-pattern some-code-to-execute-on-match
some-other-pattern ...
another-pattern ...)
it would be nice if the work of preping the patterns could be done at compile time and just emit clojure literals representing the prepared patterns, lvars are currently not emittable in code, so the cost of prepping patterns would be incurred at runtime.
this seems to turn an expression containing lvars into something you can return from a macro
(defn emittable [expr]
(postwalk
(fn [expr]
(cond
(mk/lvar? expr)
`(clojure.core.logic.minikanren.LVar.
~(.name expr)
~(.hash expr)
~(.cs expr))
(symbol? expr)
`(quote ~expr)
(seq? expr)
`(list ~@expr)
:else expr))
expr))