Hi John,

By :pre, do you mean function preconditions? eg. (fn [] {:pre [..]}) ?

How is :pre related to metadata and dispatch? AFAICT it's purely for
macroexpansion and
there is no metadata available on the precondition post-macroexpansion.

Thanks,
Ambrose

On Mon, May 27, 2013 at 9:00 PM, John D. Hume <duelin.mark...@gmail.com>wrote:

> On May 26, 2013 8:53 PM, "Mark Engelberg" <mark.engelb...@gmail.com>
> wrote:
> >
> > Another possible design choice is to store a domain-testing predicate in
> the function's metadata.
>
> Using metadata would be a much more idiomatic choice than using arity.
> Multiple arities are idiomatically used (like method overloading) to
> default arguments.
>
> An interesting detail James thought of but didn't call out is putting the
> domain check in the :pre metadata of the fn. This is an infrequently used
> Clojure feature, but it's a perfect fit for partial functions. Calling a fn
> with an argument that fails the :pre check will throw an exception, so the
> body can be written to assume it's got good input. Anyone can grab the :pre
> metadata to test for applicability, and anyone who knows clojure will have
> at least passing familiarity with the concept.
>
> Your macro can still pull apart the pattern matching forms to build the
> :pre fn, and it's still easy to do orElse-style composition.
>
> Unrelated: If you haven't already, you may want to read and follow up on
> the May 16 thread "core.match" before going very far with it.
>
> --
> --
> 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/groups/opt_out.
>
>
>

-- 
-- 
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/groups/opt_out.


Reply via email to