Reputation: 367
Whenever I try to use (load-file) on my home computer (OSX) it throws the following error:
IllegalArgumentException Parameter declaration comp should be a vector clojure.core/assert-valid-fdecl (core.clj:6732)
When I load the same file on my Windows box at work it works. What is the difference between (load-file "C:\clojure\pc-3.clj") and (load-file "/Users/myname/clojure/pc-3.clj") that is throwing the error. Other than the path structure with the slashes is different but I don't understand why this is not working on my both systems.
BTW: Other than OS both systems are running JRE 1.7_025 with clojure-1.5.1.
UPDATE: I was asked for a stack trace and I'm not sure how to do this just started working with Clojure. But emacs nrepl-error buffer listed this out for me:
java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String
RT.java:318 clojure.lang.RT$3.invoke
NO_SOURCE_FILE:1 user/eval278
Compiler.java:6619 clojure.lang.Compiler.eval
Compiler.java:6582 clojure.lang.Compiler.eval
core.clj:2852 clojure.core/eval
main.clj:259 clojure.main/repl[fn]
main.clj:259 clojure.main/repl[fn]
main.clj:277 clojure.main/repl[fn]
main.clj:277 clojure.main/repl
RestFn.java:1096 clojure.lang.RestFn.invoke
interruptible_eval.clj:56 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
AFn.java:159 clojure.lang.AFn.applyToHelper
AFn.java:151 clojure.lang.AFn.applyTo
core.clj:617 clojure.core/apply
core.clj:1788 clojure.core/with-bindings*
RestFn.java:425 clojure.lang.RestFn.invoke
interruptible_eval.clj:41 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:171 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
core.clj:2330 clojure.core/comp[fn]
interruptible_eval.clj:138 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
AFn.java:24 clojure.lang.AFn.run
ThreadPoolExecutor.java:1145 java.util.concurrent.ThreadPoolExecutor.runWorker
ThreadPoolExecutor.java:615 java.util.concurrent.ThreadPoolExecutor$Worker.run
Thread.java:724 java.lang.Thread.run
UPDATE: Found out what the problem was today. I was having the exact same problem with my Windows box turns out that the original answer was correct but my assumption that it had to do with (load-file) was incorrect. The file I was loading had a function that was not using a vector [] as part of the function itself. Clojure was doing the correct thing (but I totally forgot about this) when loading the file checking the syntax to make sure that everything was complete in the file. My function wasn't so it wouldn't load the file. I forget that LISPs do this and that it's a feature not a bug (reason why I like LISPs).
I'm new to clojure but not to LISPs and I should have realized this. The file is my study file. All the examples I retype from the REPL why studying and the reload the file with the newest to make sure I typed it in correct. It appears that when I added the newest function to file I retyped it incorrect and didn't reload the file to check it. When I went away and closed down the REPL and then came back after dinner and tried to reload the file it wouldn't load.
So sorry for being a waste of time. But thanks for the help, and quickly too. The original answer was correct I just forgot to recheck all the functions in the file.
Upvotes: 4
Views: 1307
Reputation: 91554
That error indicates that the compiler was processing something like
(defn function-name comp (do-stuff ...))
or perhaps
(defn [arg1] comp (do-stuff ...))
instead of
(defn function-name [comp] (do-stuff ...))
load-file
takes a string not a vector (load-file "path/to/file.clj)
Could it be that the code is not the same on the two systems?
Could there be a difference in path interpretation /
vs \
causing something else to get loaded?
Upvotes: 4