Вопрос

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