首页 \ 问答 \ Clojure(加载文件)给出错误(Clojure (load-file) gives an error)

Clojure(加载文件)给出错误(Clojure (load-file) gives an error)

每当我尝试在家用计算机(OSX)上使用(加载文件)时,它会抛出以下错误:

IllegalArgumentException Parameter declaration comp should be a vector clojure.core/assert-valid-fdecl (core.clj:6732)

当我在工作时在我的Windows机器上加载相同的文件时,它可以工作。 抛出错误的(load-file“C:\ clojure \ pc-3.clj”)和(load-file“/Users/myname/clojure/pc-3.clj”)有什么区别? 除了斜杠的路径结构不同,但我不明白为什么这不适用于我的两个系统。

顺便说一下:除了OS,两个系统都运行JRE 1.7_025和clojure-1.5.1。

更新:我被要求进行堆栈跟踪,我不知道如何开始使用Clojure。 但是emacs nrepl-error buffer为我列出了这个:

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

更新:找出今天的问题。 我遇到了与我的Windows框完全相同的问题,原来的答案是正确的,但我认为它与(加载文件)有关的错误。 我加载的文件有一个函数,它不使用vector []作为函数本身的一部分。 当加载文件检查语法以确保文件中的所有内容都已完成时,Clojure正在做正确的事情(但我完全忘记了这一点)。 我的功能不是这样,它不会加载文件。 我忘了LISP这样做,这是一个特征而不是一个bug(我之所以喜欢LISP)。

我是新手,但不是LISP,我应该意识到这一点。 该文件是我的学习档案。 我从REPL重新输入的所有示例为什么要学习并使用最新版本重新加载文件以确保我输入正确的文件。 看来,当我将最新的函数添加到文件时,我重新输入错误并且没有重新加载文件来检查它。 当我离开并关闭REPL然后在晚餐后回来并试图重新加载文件它不会加载。

很抱歉浪费时间。 但感谢你的帮助,也很快。 原来的答案是对的,我只是忘了重新检查文件中的所有功能。


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.

更新时间:2023-03-21 16:03

最满意答案

该错误表明编译器正在处理类似的事情

(defn function-name comp (do-stuff ...))

也许

(defn [arg1] comp (do-stuff ...))

代替

(defn function-name [comp] (do-stuff ...))

load-file接受一个字符串而不是一个vector (load-file "path/to/file.clj)两个系统上的代码是不一样的?
路径解释/ vs \导致其他东西被加载吗?


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?

相关问答

更多

相关文章

更多

最新问答

更多
  • 在javascript中创建类以创建对象并在Java中创建类和对象之间的区别(Difference between creating a class in javascript to create an object and creating an class and object in Java)
  • Facebook API:将身份验证详细信息从Javascript SDK发送到PHP SDK(Facebook API: Send authentication detail from Javascript SDK to PHP SDK)
  • 如何停止队列动画jquery?(How can I stop queue animation jquery?)
  • 使用C#的井字游戏中的人工智能(Artificial Intelligence in Tic-Tac-Toe using C#)
  • 多少流量可以共享虚拟主机(对于Python Django站点)支持?(How Much Traffic Can Shared Web Hosting (for a Python Django site) support?)
  • 带有CIFilters的CAShapeLayer(CAShapeLayer with CIFilters)
  • 如何在Angular 2中读取JSON #text(How to read in Angular 2 the JSON #text)
  • 如何在xml中读取自闭标签的属性?(How to read self closing tag's attribute in xml?)
  • 无法使用http put将图像上传到亚马逊S3(Cannot upload image to amazon s3 using http put)
  • 文件结束无限循环(end of file infinite while-loop)
  • 在cpp的模板(template in cpp)
  • 在构建库时,clang和clang ++有什么区别?(What's the difference between clang and clang++ when building a library?)
  • ng类中的表达式(expression inside ng-class)
  • 在PHP中获取随机布尔值true / false(Get random boolean true/false in PHP)
  • 管道的高效分块用于严格的字节串(Efficient chunking of conduit for strict bytestring)
  • Python ternary_operator(如果其他标志做了其他操作,则执行其他操作)(Python ternary_operator (do-somthing if flag else do-another))
  • Sencha Touch面具发布(Sencha Touch mask ondisclosure)
  • 验证脚本上的通知[重复](Notices on validation script [duplicate])
  • 朋友功能(friend function)
  • 基于角坐标平移和变换平面几何(Translate and transform plane geometry based on corner coordinates)
  • Rails:'如果在本地运行'条件javascript标记包括(Rails: 'if running locally' conditional javascript tag include)
  • 解压文件(Unzipping files)
  • 使用ui-router以角度加载变量状态(loading in variable states with ui-router in angular)
  • 创建Azure云服务需要多长时间?(how long does it take to create an Azure Cloud Service? How to view log information?)
  • 指向整数的指针数组(Array of pointers to integers)
  • Laravel服务提供商没有看到我的包的主要类(Laravel service provider does not see the main class of my package)
  • 这个关于VSS / RSS / PSS / USS的解释是否准确?(Is this explanation about VSS/RSS/PSS/USS accurate?)
  • 在Django-Admin中通过row-id排序显示项目(Ordering the display items by row-id in Django-Admin)
  • 如何使用cythonize启用`--embed`?(How to enable `--embed` with cythonize?)
  • 用于将文本多行设置的Excel脚本(Excel script for ereasing text multiple rows)