3
votes

The examples I've seen of main methods defined in clojure all use gen-class, together with (defn -main ...). Is it possible to define a class with an executable main method using deftype?

2

2 Answers

8
votes

it is not possible, because interfaces (protocols) that deftype can implement cannot have static methods.

-1
votes

A main method only makes sense if you AOT compile it (with gen-class or similar).

If you tried to define it in any other way, then it wouldn't be possible to use it since you would need to launch the clojure compiler / environment first. So you'd have to start the app by calling some other main() method instead.....