Oops. That is what I meant, but I don't know why I thought pre- and
post-conditions get stored in metadata. It would be handy for :pre. Thanks,
Ambrose.

To the OP, I would still recommend using metadata to store the
applicability test and also making it a precondition of the fn in a partial
function implementation, but that will require more effort than I thought.
On May 27, 2013 8:12 AM, "Ambrose Bonnaire-Sergeant" <
abonnaireserge...@gmail.com> wrote:

> 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.
>
>
>

-- 
-- 
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