I've been thinking lately how to seamlessly merge clojure-py and clojure-jvm code in the same packages. This is something I know has been discussed in the past, but I'm just looking for ideas/brainstorming on how we can solve this problem.
Let's begin by explaining the problem. Let's assume that my project needs a platform specific way to convert a int to a string: On clojure-jvm: (defn to-string [i] (.toString Integer i)) On clojure-py: (defn to-string [i] (py/str i)) On Clojurescript: (defn to-string [i] (.toString i)) We could do this inline (inside a common .clj file): (for-platform "jvm" (defn to-string [i] (.toString Integer i)) "python" (defn to-string [i] (py/str i)) "js" (defn to-string [i] (.toString i))) But this gets ugly real fast. My idea, would be to provide some sort of hook to the compiler, that would be cross-platform. The compiler, when looking for a namespace, would find all files in a given folder that match the required namespace: /test/to_string.clj /test/to_string.cljpy /test/to_string.cljs /test/to_string.cljclr These function hooks would then pick the best entry based on the extension, defaulting to .clj if no better option exists. Since these functions could be composable it would be possible to also dispatch on platform versions: /test/to_string.cljpy26 ; Python 2.6 code /test/to_string.clj7 ; JVM 7 code It seems to me that this would be a very clean way to allow clojure programs to be cross-platform. The side-effect is that it would force non-standard code out into separate namespaces where they can be easily maintained. If someone wanted to port the project to a new platform, he would need only to find existing platform overrides, and create new entries. Thoughts? Timothy Baldridge -- 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