On page 186 (last page of chapter 7) it says “The first thing we need to do is import (not use or require) our MidiNote protocol from the examples.midi namespace”.
I could not find a reason for why import, rather than use or require, should be used in this case. I am very new to Clojure but as far as I can tell, “import” is used only for importing Java classes.
When I tried using generator.clj from the REPL by running:
user=> (require '[examples.generator :refer :all])
, the “import” did not work: I got the following error:
CompilerException java.lang.ClassNotFoundException: examples.midi.MidiNote, compiling:(examples/generator.clj:11:1)
I removed the import statement and added the following require to the ns
statement at the top of generator.clj
:
(:require [examples.midi :refer [MidiNote key-number perform to-msec]])
After this change I was able to run generator.clj from the REPL successfully.