I am trying to understand how Clojure hierarchies work, with the derive and is-a? constructs. I'm not sure how I would use these with the maps and records in my program. Has anyone used these?
I find your question a bit vague. Have you read the documentation on the Clojure website?
http://clojure.org/multimethods
I find the examples there quite 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's also this blog post with a more "real-world" example:
http://www.prodevtips.com/2010/06/20/clojure-inheritance/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With