I'm relatively new to Clojure, and I just want to make sure I understand things correctly. There are two issues that I'm struggling with. Neither is major, but if there is a good solution, I'd like to find out.
1) You must define a method before you call it from another function. Stylistically, I prefer to define helper functions after the main function, but that seems to cause errors. If I move them in front of the main function, the errors go away. I don't know if there's some way to declare the methods before you define them (like C header files). 2) To have two or more functions with the same name and a different arity, you must define them in a single (defn...). For example, the following code: (defn good ([a] (println (str "argument: " a))) ([a, b] (println (str "arguments: " a ", " b)))) (defn bad [a] (str "argument: " a)) (defn bad [a b] (str "arguments:" a ", " b)) (good "foo") (good "foo" "bar") (bad "foo") (bad "foo" "bar") Generates the following output: argument: foo arguments: foo, bar Exception in thread "main" java.lang.IllegalArgumentException: Wrong number of args passed to: core$bad (SandBox.clj:0) This crops up when I have a function that was created using a function- building macro, and I wanted to define a wrapper with the same name that allowed me to enter the arguments in a simpler manner. Also, it just feels odd. You don't get an error when defining the same- named function--but suddenly neither version works. That's a pretty serious side-effect. So maybe this is just a bug? Thanks, -Rich- --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---