If I've defined a function with defn and a condition map containing :pre and :post forms, how can I retrieve that condition map? I notice that

(meta #'fn-name) 

doesn't contain the condition map. I'm specifically looking for the :pre conditions (in order to derive a predicate that's equivalent to them but doesn't assert). Is there any way to recover them other than walking the function body looking for asserts?

有帮助吗?

解决方案

Unfortunately, they aren't stored anywhere after processing the fn macro. They're prepended/appended directly to the body of the function as asserts. You can check the relevant source lines in fn.

As a workaround, you could probably write your own variant of defn that grabs the :pre and :post conditions and stores them as metadata.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top