在clojure中的gen-class并立即使用它

时间:2017-03-06 04:42:46

标签: clojure

是否可以使用gen-class创建一个类而不编译它?我正在关注轨道教程,并且遇到了问题:https://github.com/orbit/orbit/wiki/Getting-Started%3A-Hello-World#actor-implementation

我可以使用gen-interface创建一个界面:

(import cloud.orbit.actors.Actor)
(import cloud.orbit.actors.runtime.AbstractActor)
(import cloud.orbit.concurrent.Task)

(gen-interface
 :name example.Hello
 :extends [cloud.orbit.actors.Actor]
 :methods [[sayHello [String] cloud.orbit.concurrent.Task]])

gen-class无法正常工作,而且我遇到了问题

(gen-class
 :name example.HelloActor
 :extends [cloud.orbit.actors.runtime.AbstractActor]
 :implements [example.Hello]
 :methods [[sayHello [String] cloud.orbit.concurrent.Task]])

2 个答案:

答案 0 :(得分:1)

你看过这个流程图吗?

https://github.com/cemerick/clojure-type-selection-flowchart

enter image description here

我对gen-classproxy等人没有太多经验,但您应该确保查看"代理"下的所有选项。 on the Clojure Cheatsheet.

答案 1 :(得分:0)

简短的回答是:不,您不能使用user@user:$ git branch -a 进行编译。

更有趣的答案是:是的,如果您的代表具有正确的设置,则可以从代表中使用gen-class

以下是Boot的有效示例:https://gist.github.com/jeroenvandijk/8187413d24433545eeb9579538a903f7#file-repl_compile-clj-L39-L52