Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Clojure Polymorphism

You're reading from   Clojure Polymorphism Leverage Clojure's polymorphic tools to develop your applications

Arrow left icon
Product type Paperback
Published in Nov 2019
Publisher
ISBN-13 9781838982362
Length 56 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Paul Stadig Paul Stadig
Author Profile Icon Paul Stadig
Paul Stadig
Arrow right icon
View More author details
Toc

Analysis

There are several dimensions along which we can compare these implementations: flexibility, performance, external integration, and cross-platform compatibility.

Flexibility

If "flexibility" is defined as having control over when and where the abstraction can be extended to a type, then the "plain function" approach is the least flexible. You must define all of the dispatch in one static cond. If you want to extend the abstraction to another class, then you have to add another clause to the cond. The other approaches give you the flexibility to define the conversion of a type in whatever namespace you want. You would obviously have to use this flexibility for good and not for evil.

If "flexibility" is defined as having the most leeway with dispatch, then the "multimethod" approach is the most flexible. I have not talked about derivation hierarchies, but multimethods can use ad hoc inheritance hierarchies for dispatch. You will have many more opportunities...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image