Hi, Aaron, Rob
thank for the reply. I actually thinking that something that is straightforward and less involving (without daemon or lein). What happen is that I like to write a script in intellij editor, and then choose run, clojure will check for main function in current file , and invoke it. So kind of straightforward just like Java running a main method in current class. I find this way of development useful, because I can quickly mook up code in main function and experiment with it quickly. This could be a great feature to have in clojure out of the box. So lein way requires a namespace, maybe i can try that. Not too sure, if that is the way, maybe I can request if Intellij can add this ability in its clojure plugin. flow will be something like: - When run is invoked, Intellij will check the current namespace of the file, and then invoke lein run -m <namespace> if main- is found . thank :} On Wednesday, February 26, 2014 5:50:43 PM UTC+8, macdevign mac wrote: > > Hi, > is there a function to determine if the clojure code is running as library > or as script ? > > In ruby, there is > > if __FILE__==$0 > # this will only run if the script was the main, not load'd or require'dend > > In Java, we could include main method in class, and choose to run it, > > How about clojure ? > > Is there any function/macro like the following ? > > (run-main > (code ......)) > > > so that it can be run standalone, or it can be ignored running as > library. I find this useful for quick experimenting. > > thank > > > -- 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/groups/opt_out.