Yes, the :post is easily done as well. I just wanted to throw up a quick
proof-of-concept.

Tim


On Mon, Jul 11, 2011 at 1:52 PM, Ben Mabey <b...@benmabey.com> wrote:

> **
> On 7/11/11 11:40 AM, Timothy Washington wrote:
>
> Note: This message was originally posted by '  Shantanu' on the "*Re:
> Clojure for large programs*" thread.
>
>  I took a look at   Shantanu's macros, and I like the concept a lot. But I
> would prefer something baked into the :pre condition itself. The reason is
> that it just removes a layer of indirection. If you dig into '*
> clj/clojure/core.clj*', you can see that the 'fn' macro is using 'assert'
> to test these conditions. Assert allows error messages to be applied, ie:
>
>  *user => (assert false) *
>
> *user => (assert false "fubar") *
>
>
>
>  However, (defmacro fn ...) assumes that just the boolean condition is
> being passed in, A). But I'd like to have the option to pass in a message
> B).
>
>
>  *A) *
>
>  *(def fubar *
>
> *  (fn []*
>
> *    {:pre [ (true? false) ] }*
>
> *    (println "Hello World")))*
>
> *(fubar)*
>
> *
> *
>
> *B) *
>
> *(def thing *
>
> *  (fn []*
>
> *    {:pre [ [(true? false) "A false message"] ] }*
>
> *    (println "Hello World")))*
>
> *(thing)*
>
>
>
>  I reworked the 'fn' macro, only for the :pre condition, as a
> demonstration (see here <http://pastebin.com/fETV1ejJ>). The calling
> semantics don't change that much. Is there any interest in putting this into
> core? I'd use Shantanu's workaround otherwise, or in the interim.
>
>  Thanks
>
> Tim Washington
> twash...@gmail.com
> 416.843.9060
>
>
> I'd like to see something like this added as well since I sometimes write a
> comment by conditions to help remind myself of why they are present. One
> comment on the patch that is probably obvious, but if we change the API for
> :pre we would want to update the :post API as well to keep them consistent.
>
> -Ben
>
> --
> 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 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

Reply via email to