Can you show me an example of what you want?
A long time ago I used lein to create my project which I've been developing for several months. It created the files in the project which I just used as a template but didn't understand on day 1. How when I look at the main ns declaration, I wonder whether the form (:gen-class)
needs to be removed. What purpose does it serve?
(ns clojure-rte.core
(:require [clojure.set :refer [union]]
[clojure.pprint :refer [cl-format]]
[clojure-rte.cl-compat :refer [cl-cond]]
[clojure-rte.util :refer [with-first-match call-with-collector
fixed-point
visit-permutations rte-constantly rte-identity
partition-by-pred
print-vals sort-operands member]]
[clojure-rte.type :as ty]
[clojure-rte.dfa :as dfa ]
[clojure-rte.rte]
[clojure-rte.memoize]
[clojure-rte.api]
[clojure-rte.type-extend]
)
(:gen-class))
if you don't aot compile, perhaps it is not necessary. this page might have some useful details: https://clojure.org/reference/compilation
does :gen-class
simply allow me to define a function named -main
which is then automatically called whenever the class is loaded?
No, it compiles a class with a static method named main (the - is the default prefix)
There is no automatic anything
When Java runs, it needs a class with a staric main to invoke
So :gen-class + a compile can give you a Java main entry point
Or you can just use clojure.main for the same purpose - it knows how to call the -main method on a Clojure ns (compiled or not)
what does a "Java main entry point" do? is that the function which is automatically run when java is started from the unix command line?
G'morning. Is there any way to add middleware to the nrepl that cursive sets up, when you choose the nrepl option for your repl configuration?
Yes - you start Java with a class name and it loads that class and invokes itβs static main method
And I also see that in cursive, there is a green play triangle if there is a -main
method and :gen-class
has been specified.
That's pretty useful actually π