I see this old post by Fogus:


With this example:

(defn constrained–fn [f x]
  {:pre  [(pos? x)]
   :post [(= % (* 2 x))]}
  (f x))

But I see this modern example:


(defn func ^{:pre [(pos? x)] :post [(< % 100) (> % 1)]} [x] (+ 1 x))

Where it is in the metadata. 

But here I still the old style:


(defn constrained-sqr [x] {:pre [(pos? x)] :post [(> % 16), (< % 225)]} (* 
x x))

I was away from Clojure for a few years, so I think it I missed some of its 
evolution. Is one of these styles favored? 

I'm struggling with an issue where I cannot get the error to show up, even 
when I deliberately send in data that would cause the assertion to return 

My function started: 

(defn get-cisa-advisories
   :pre [(set? cisa-advisory-urls)]
   :post [(vector? %)]
  (println "get-cisa-advisories")

When I called this with a vector, I got no error, but the app silently 
died. I'm confused about this. The call to this function is wrapped in a 
try/catch block, and that assertion must have thrown an error because that 
is where the app dies, yet I couldn't see the exception in my catch block. 

You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
For more options, visit this group at
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to