So in this particular case I wouldn't care, but in general I'd expect
the prefer-method stuff to kick in. :)



On 25 October 2010 10:54, Mark Nutter <manutte...@gmail.com> wrote:
> I tried to have a go at this, but then I realized it's a bit difficult
> to specify. For example, if you have
>
> (defmethod bar [42 _] ..) ; and
> (defmethod bar [_ 16] ..)
>
> which one should be called when you give it (bar 42 16)?
>
> Mark
>
> On Sat, Oct 23, 2010 at 5:16 PM, Paul Richards <paul.richa...@gmail.com> 
> wrote:
>> Hi,
>> I have a multimethod which is dispatched on two arguments:
>>
>> (defmulti bar (fn [x y] [x y]))
>> (defmethod bar [1 2] ..)
>> (defmethod bar [3 4] ..)
>>
>> Is there a way I can define methods on this which use "wildcards"?
>>
>> E.g.:
>>
>> ; To match any call with 42 as the 1st argument
>> (defmethod bar [42 _] ..)
>>
>> ; To match any call with 16 as the 2nd argument
>> (defmethod bar [_ 16] ..)
>>
>> The above syntax doesn't seem to work, neither does using ':default'
>> in place of the '_'.
>>
>> If this is not possible, is there a common pattern I should implement 
>> instead?
>
> --
> 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



-- 
Paul Richards
@pauldoo

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