Here's a simplification of an exercise I was trying to write. We have a 
two-level hierarchy of objects:

    (derive ::starship ::thing)
    (derive ::gaussjammer ::starship)

We have a generic function that uses both arguments:

    (defmulti collide (fn [one two] [(type one) (type two)]))

We have these two specializations:

    (defmethod collide [::starship ::starship] ...)
    (defmethod collide [::gaussjammer ::thing]

Those are considered ambiguous in the face of:

    (collide some-gaussjammer some-starship)

A `prefer-method` is required:

    (prefer-method collide [::gaussjammer ::thing] [::starship ::starship])

Why? In what cases would a programmer prefer something like the second match? 


-----
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
Writing /Functional Programming for the Object-Oriented Programmer/: 
https://leanpub.com/fp-oo


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