Once you've AOT compiled that (which is necessary for the class to be actually generated), slurp won't be called again. Beware, however, that `def` (and hence `slurp`) will be executed by the compiler, at compile time, in the context (classpath, cwd, etc.) of the compiler, which may not be what you want.
Note that you can easily test that by replacing your def with: (def parser (do (println "def parser executed") (slurp ".....))) If you want the parser to be slurped once per execution, you can use an atom and a function, something like: (let [p (atom nil)] (defn parser [] (swap! p (fn [p] (if (nil? p) (slurp "....") p))))) You can then access your parser with (parser), which will only slurp the file once. (If it matters, there are alternatives that will not keep on paying the atom update cost.) On 14 August 2015 at 10:59, Thomas Goossens <cont...@thomasgoossens.be> wrote: > When a java class uses the compiled Test (gen-class) from test namespace. > Everytime the static function -run is called, will parser be slurped again > or only once ? > > (ns test (:gen-class :name Test :methods [ ^:static [run > [] String])) (def parser (slurp "......")) > > (defn -run [] ;... do something with parser ) > > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.