문제

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