Reputation: 47441
I am familiar that scala classes / objects can be called from clojure, as scala compiles to bytecode, and clojure is comfortable with it.
However is it as painless calling clojure functions, and importing namespaces from scala ?
I would like to mix the excellent lift framework and clojure, basically call clojure code from lift.
Upvotes: 17
Views: 4990
Reputation: 71
FWIW, I had a similar experience recently. It is not always straight forward to consume scala libraries in a clojure codebase. If the library authors have kept the none scala consumers in mind while designing the api, the integration can be trivial. If not you may have to learn the details of what java interface is produced by the scala library you are trying to consume.
I recently wrote a documentation about this exact topic (https://github.com/grandbora/clojure-scala-cantrips#clojure-scala-cantrips) and there are some clojure libraries out there that provides sugar syntax for consuming scala libraries.
Upvotes: 0
Reputation: 33029
Semantics for imports in Scala are basically the same as Java. You should be able to get the info you need by reading up on how to invoke Clojure code from Java, then apply the same principles in Scala.
If you want to compile your Clojure code and include it as a JAR in your classpath then this post should be relevant:
If you'd rather dynamically compile/interpret the .clj files then you should read this:
Clojure Programming: Invoking Clojure from Java
The first option seems a lot nicer to me.
Upvotes: 14