Clojure中-toString和.toString的区别(The difference between -toString vs .toString in Clojure)
在关于
:gen-class
解剖中的gen-class
的解释之后,我使用leiningen
来获取类文件。
leon new pinger
创建一个项目。cd src
和mkdir some
并在mkdir some
创建了一个Example.clj
文件。- 在
project.clj
添加:aot [some.Example]
(或:aot :all
)。Example.clj如下所示:
(ns some.Example (:gen-class)) (defn -toString [this] "Hello, World!")
然后我执行
lein compile
来获取target
目录中的类。然后,我用
lein repl
执行这段代码。(-toString (some.Example.)) ; should return "Hello, World!"
但是,我收到了此错误消息。
CompilerException java.lang.RuntimeException: Unable to resolve symbol: -toString in this context, compiling:(/private/var/folders/nw/dmb7jh3d2hq89296z2gnntqm0000gn/T/form- init7145760420048735997.clj:1:1)
.toString
工作正常。user=> (.toString (some.Example.)) "Hello, World!"
该网站解释说,我应该从
-toString
和.toString
获得相同的结果,但是我只用.toString
获得了正确的结果。Clojure中的
-toString
和.toString
什么区别? 为什么-toString
在示例中引发错误?Following the explanation about
:gen-class
in The Anatomy ofgen-class
, I usedleiningen
to get the class files.
leon new pinger
to create a project.cd src
andmkdir some
and created aExample.clj
file in it.- Added
:aot [some.Example]
(or:aot :all
) inproject.clj
.The Example.clj is as follows:
(ns some.Example (:gen-class)) (defn -toString [this] "Hello, World!")
Then I executed
lein compile
to get the classes intarget
directory.Then, I was executing this code with
lein repl
.(-toString (some.Example.)) ; should return "Hello, World!"
However, I got this error message.
CompilerException java.lang.RuntimeException: Unable to resolve symbol: -toString in this context, compiling:(/private/var/folders/nw/dmb7jh3d2hq89296z2gnntqm0000gn/T/form- init7145760420048735997.clj:1:1)
.toString
works fine.user=> (.toString (some.Example.)) "Hello, World!"
The website explains that I should get the same results from both
-toString
and.toString
, but I got only correct results with.toString
.What's the difference between
-toString
and.toString
in Clojure? Why-toString
raises an error in the example?
原文:https://stackoverflow.com/questions/21392494
最满意答案
您可以为应用容器,数据库和环境指定部分配置文件
然后在构建时激活多个配置文件,例如:
mvn package -P weblogic,mysql,development
您是否应该进行特定于环境的构建(开发/发布/测试)?
you can specify partial profiles for app container, db and environment
Then activate multiple profiles when building for example:
mvn package -P weblogic,mysql,development
also should you be doing environment specific builds (development/release/test)?
相关问答
更多-
我如何为不同的环境构建安装我的maven pom?(how do i setup my maven pom for different environment builds?)[2023-11-11]
您必须在您的pom.xml中定义不同的环境配置文件environment test ... -
Maven 3(从beta 1开始)现在支持并行构建作为一个实验功能。 例如, mvn -T 4 clean install # Builds with 4 threads mvn -T 1C clean install # 1 thread per cpu core mvn -T 1.5C clean install # 1.5 thread per cpu core 完整的文档可以在Maven wiki上找到。 https://cwiki.apache.org/confluence/display/M ...
-
假设你的Nexus是本地的,我会考虑为什么会有低劣的下载速度,因为在本地使用像Nexus和Artifactory这样的东西是当前缓存最简单的方法。 他们将管理缓存依赖项的生命周期,以便您不再需要缓存更长时间的依赖项以满足需要,并且可以在使用新依赖项时添加新依赖项。 如果您只想在单个作业中进行缓存,则output的缓存依赖项文件夹(用于maven的.m2文件夹),并将其用作另一个任务的input 。 如果你想在作业之间缓存,那么你可以: 使用缓存文件夹构建Docker镜像,但是当更新依赖关系时,您需要管理该镜 ...
-
您可以为应用容器,数据库和环境指定部分配置文件 然后在构建时激活多个配置文件,例如: mvn package -P weblogic,mysql,development 您是否应该进行特定于环境的构建(开发/发布/测试)? you can specify partial profiles for app container, db and environment Then activate multiple profiles when building for example: mvn package - ...
-
需要Maven 3.2.1或更高版本来清洁地使用pom文件的主
corrdinate中的变量。 Maven 3.2.1 or later is required to cleanly use variables in the main corrdinate of a pom file. -
Maven Tomcat 7 - 构建(Maven Tomcat 7 - Build)[2022-11-04]
用于部署的用户必须具有manager-script角色。 用户名必须与您在settings.xml中使用的用户名相匹配。插件中的URI应该是/ manager / text http://localhost:8090/manager/text 注意:admin-gui + admin-script角色用于主机管理器UI和RES ... -
我不知道这个问题的确切原因,但我解决了我安装另一个带有相同插件的Eclipse并更改工作区的位置。 新的日食,相同的工作空间 - 同样的问题新的日食,新的工作空间 - 解决了。 I don't know the exact cause to this problem but i solved it my installing another Eclipse with same plugins and changing the location of the workspace. New eclipse, s ...
-
阅读额外的评论/改进问题,听起来确实像集成测试 。 有一些需要整合测试库,如JBehave , Serenity , Cucumber等,这可能更适合设置它。 使用TestNG,您可以创建3个测试,其中每个下一个测试都取决于之前的测试。 请参阅下面的代码示例,来自testng依赖性测试 package com.mkyong.testng.examples.dependency; import org.testng.annotations.Test; public class App { @Te ...
-
如果它们都使用相同的内存,你如何分开2个处理器? 如果他们通过英特尔的MULTIBUS访问相同的内存,那么LOCK前缀就会产生这种序列化。 如果内存本地安装在一个处理器的电路板上,则LOCK前缀不会阻止其他处理器通过MULTIBUS进入并同时访问该板的内存。 在这种配置中,程序员必须玩其他游戏来锁定总线(并在完成存储器操作后解锁总线)。 How do you separate the 2 processors if they both use the same memory? If they accesse ...
-
SSD写入速度比读取速度慢但你没有dsk访问延迟支付,因此几乎总是比HDD快,特别是对于吐出大量小文件的Maven构建(即非常随机的访问) 阅读SSD与HDD性能差异的这个合理的总结,但我相信,对于每个Maven构建,您会发现它是访问延迟而不是写入吞吐量会影响您的构建速度。 TL; DR用于SSD SSD write speed is slower than read speed but you don't have dsk access latency to pay, so will nearly alw ...