On Monday, May 7, 2012, Jim - FooBar(); wrote:

> On 07/05/12 21:59, Aaron Cohen wrote:
>
>> You invoke your multimethod with 2 arguments. You need to change your
>> dispatch function to take 2 arguments (it can ignore them if you don't need
>> them).
>>
>
> Thanks Aaron - it did the trick! I did not realize that multi-methods
> cannot be overloaded...
>
> They can be, you just use either an overloaded or varargs dispatch
function.


>>  Well, i hate nested ifs so yeah this is a bit clearer and more
> extensible. You know very well that there is really only one OS...aaaa and
> stinky windows of course! ;-)
>

I know this is a very common paradigm in OO (with principles such as
"prefer polymorphism to nested ifs"). I want to write a longer essay here
on my feelings about when to use polymorphism in clojure but not on my
iPhone ;)

Suffice it to say, there are definitely cases where polymorphism makes
sense in clojure, particularly when working with datatypes. I'd recommend
thinking about when it's appropriate though, particularly if it's a
lingering OO impulse that is causing you to reach for this tool.

--Aaron

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