Skip to content

Using ClojureCLR in a C# project

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

To use ClojureCLR in a C# project, include the ClojureCLR runtime via NuGet. The repo is at http://www.nuget.org/packages/Clojure/. 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 clojure.java.api.Clojure class in ClojureJVM. More information is to be found at http://clojure.org/java_interop#Java Interop-Calling Clojure From Java .

For example:

IFn load= clojure.clr.api.Clojure.var("clojure.core", "load");
load.invoke("some.thing");
Clone this wiki locally