2
votes

Can someone explain this to me? I think I understand that (defn -main) is declaring a main method that would be recognised by Java and that if you use this in conjunction with a namespace with (:gen-class) that you can fool Java into thinking clojure is object oriented, however I can't work out what the purpose is if you just create a function like

(def- add2 (partial + 2) )

or (defn- my-function...)

Can anyone explain this simply or correct me if the above assumptions are wrong?

**Edit - I understand what a partial function does :) I'm just wondering if there's a difference between above and (def add2 (partial + 2))

1

1 Answers

9
votes

Functions defined with defn- aren't accessible outside of the namespace they were defined in. In other words, they are private.

Take a look at the source of defn-. This macro evaluates to a call to defn with {:private true} merged into the metadata hash.