3

How would I eval to the following?

(defn run-clojure-func []
  (println "welcome"))

(defn -main [& args]
  (eval (*func* (first args)))

java exam.Hello "run-clojure-func"
1
  • 1
    Sorry, I don't understand the question. Can you ask in words? What is -main supposed to do? Commented Oct 5, 2010 at 7:12

1 Answer 1

7

Two versions for you to consider – entirely equivalent, but useful as points of comparison:

(defn -main [& args]
  ((-> args first symbol resolve)))

and this, using destructuring and no -> macro usage:

(defn -main [[fn-name]]
  ((resolve (symbol fn-name))))

resolve is obviously the key. The docs are your friend. :-) Also, as an unfair generalization, eval is almost never necessary.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.