Using ClojureCLR in a C# project

Nicolas Kassis edited this page Jun 16, 2015 · 4 revisions

To use ClojureCLR in a C# project, include the ClojureCLR runtime via NuGet. The repo is at From the NuGet console:

Install-Package Clojure

The package includes runtimes for .Net 3.5 and 4.0. ClojureCLR is packaged in the single file Clojure.dll that contains the runtime. (The many DLLs required have been ILMerge'd.) Also, the DLLs are signed so that they can be included in signed projects.

Also included in the package are Clojure.Main.exe and Clojure.Compile.exe. They are in the tools\ subdirectory.

In general, one should not call any methods from the clojure.lang.X classes directly, even those in clojure.lang.RT, which provides runtime support for the Clojure core functions. For example, RT.load supports clojure-core/load, but the Clojure load function does input massaging and other work around the call to RT.load.

Instead, use the methods in the clojure.clr.api.Clojure class. This class parallels the class in ClojureJVM. More information is to be found at Interop-Calling Clojure From Java .

For example:

IFn load= clojure.clr.api.Clojure.var("clojure.core", "load");