The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

2. P 103-106: I feel like these Java examples distract from your nice Clojure books. I love aspects of Java, but I think you are losing focus here. Will all of your readers be fluent in Java? Or comfortable enough in Java so these pages make sense?

3. P 109: At first, I was confused by the & options in the defmulti.

4. P 109, just before subsection 4.3.2: Is the key advantage of polymorphism to avoid the pain adding new rules about affiliates and percentage? Yes, the cond form will get messy.

Perhaps even better you are using the type system to decouple different type-based functionality.

5. P 109-110: Can you put a diagram in for where each argument goes?
For me to understand what is going on, I had to pull up a Clojure interpreter and enter these defn, defmulti, defmethods and defs.

I have a good deal of experience, so I hoped I could read this section and the next time I was near a Clojure interpreter, then I could just recall enough from this example to type a similar one to enjoy. I had to look back and draw a diagram.

Here is my attempt at tweaked version:

;;
;;
;;
;; In different contexts, we want to apply this function to different methods.
;; This function has not been modified in any way to be applied polymorphically.
;;
(defn fee-amt [percentage user]
(float (* 0.1 percentage (:salary user)))

;;
;;
;; The next macro indicates an method a-f will be dispatched based on the value of :referrer
;;
(defmulti a-f :referrer)

;;
;;
;; These are methods for dispatching the fee-amt function.
;; These methods are selected by the :referrer which is one of :mint.com, :google.com and :default
;;
(defmethod a-f :mint.com [user] (fee-amt 0.03 user))

(defmethod a-f :google.com [user] (fee-amt 0.01 user))

(defmethod a-f :default [user] (fee-amt 0.05 user))

;;
;; These defs have :referrers to use the type system to differentiate the
;; functions. Along with these different references are the appropriate :salaries.
;;
(def user-1 {:login "Rob" :referrer :mint.com :salary 100000})

(def user-2 {:login "Kyle" :referrer :google.com :salary 90000})

(def user-3 {:login "Celeste" :referrer :yahoo.com :salary 190000})

;;
;; The selection keys are given here immediately after the :referrer key word.
;; The :salary values are also given in the def statements above.
;;
(a-f user-1)
(a-f user-2)
(a-f user-3)

6. P 114, -9: This is much simpler than creating the whole double-dispatch mechanism in a language like Java or C++ that does not support it. This is correct, but the sentence is awkward to read.

7. P 114, -3: the word looks is split across lines. But, more significantly you are hedging your words too much: Sometimes, a hierarchy may involve... How about either
a. A hierarchy may involve...
b. Sometimes, a hierarchy involves