The problem is: how do you tell the difference between a pre- and post-condition map, and a map you want to return from the function?
The only way to do it is to explicitly return nil. - James On 15 February 2016 at 04:48, Laws <smashcompan...@gmail.com> wrote: > If I write this in a file: > > (defn different-order [order] > {:pre [ > (map? order) > (:waiter order) > (:customer order) > (:menu-item-name order) > ] > :post [ > (map? %) > (:waiter %) > (:customer %) > (:menu-item-name %) > ]} > > ) > > and then I try "lein uberjar" I get: > > Exception in thread "main" java.lang.RuntimeException: Unable to resolve > symbol: % in this context > > but if I add a line of code to the function body: > > (defn different-order [order] > {:pre [ > (map? order) > (:waiter order) > (:customer order) > (:menu-item-name order) > ] > :post [ > (map? %) > (:waiter %) > (:customer %) > (:menu-item-name %) > ]} > > (println "hi") > > ) > > Then it compiles. > > At the very least, we should have a better error message than "Unable to > resolve symbol: % in this context". Something like "function definition is > incomplete" would at least communicate what the problem is. > > But if this really needs to be treated as an error, I would like to know > why it needs to be an error. This does not generate an error: > > (defn different-order [order] ) > > So why does adding a :post assertion create a compile time error? I'd > expect a runtime error, but not a compile time error. > > -- > 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 > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- 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. For more options, visit https://groups.google.com/d/optout.