05 Apr 2012, 10:21
Generic-user-small

Umesh Telang (1 post)

Apologies if this is too detailed a question to be asking, but I’ve been getting all the code examples to work until this point (section 6.6 reify).

When I load the src/examples/midi.clj into a repl (I’m using Emacs) and then attempt to load src/examples/generator.clj, I get the error at the bottom of this post. I can see key-number declared in the MidiNote protocol definition in midi.clj, and the equivalent “reification” in generator.cj seems to match in name and argument signature (if that’s relevant…).

If someone can point in the general direction as to where I’m going wrong… or how to look for a resolution, that would be much appreciated!

Thanks, Umesh

ERROR:

Unable to resolve symbol: key-number in this context [Thrown class java.lang.RuntimeException]

Restarts: 0: [QUIT] Quit to the SLIME top level

Backtrace: 0: Util.java:156 clojure.lang.Util.runtimeException 1: Compiler.java:6720 clojure.lang.Compiler.resolveIn 2: Compiler.java:6664 clojure.lang.Compiler.resolve 3: Compiler.java:6625 clojure.lang.Compiler.analyzeSymbol 4: Compiler.java:6198 clojure.lang.Compiler.analyze 5: Compiler.java:6177 clojure.lang.Compiler.analyze 6: Compiler.java:3452 clojure.lang.Compiler$InvokeExpr.parse 7: Compiler.java:6411 clojure.lang.Compiler.analyzeSeq 8: Compiler.java:6216 clojure.lang.Compiler.analyze 9: Compiler.java:6177 clojure.lang.Compiler.analyze –more–

08 Jun 2013, 08:23
Generic-user-small

Suresh Iyer (6 posts)

I got the same error message, and since Google search for the error message had only this page, decided to spend some time understanding the error message. Since it said “cannot resolve symbol”, I thought that perhaps inside a reify, if we want to access any other method, we need to use the dot operator (“object.method” in C based languages). So made the following changes and it worked!.

  (.noteOn midi-channel (.key-number this) velocity) ; 1
  (Thread/sleep (.to-msec this tempo)))))]           ; 2
  (examples.midi/perform (repeat 15 rand-note)))     ; 3

1 - key-number to “.key-number” 2 - to-msec to “.to-msec” 3 - perform to “examples.midi/perform” (namespace scoped call)

Now I am not sure why you need the dot notation inside reify when the same is not required in extend-record calls in the previous section(s). Hope someone else can explain that.

Hope this helps. Thanks.

  You must be logged in to comment