How to use clojure hierarchies?

I'm trying to understand how Clojure hierarchies work, with output and is-a constructs ? . I'm not sure how to use them with maps and records in my program. Has anyone used them?

+5
source share
1 answer

I find your question a little vague. Have you read the documentation on the Clojure website?

http://clojure.org/multimethods

I find examples that are pretty easy to follow:

user=> ::rect
:user/rect
user=> (derive ::rect ::shape)
nil
user=> (parents ::rect)
#{:user/shape}
user=> (derive ::square ::rect)
nil
user=> (ancestors ::square)
#{:user/shape :user/rect}
user=> (isa? ::square ::shape)
true

There is also this blog post with a more “real” example:

http://www.prodevtips.com/2010/06/20/clojure-inheritance/

+5
source

All Articles