This project is read-only.

C# Calling IronScheme

Feb 25, 2010 at 10:12 PM
Edited Feb 27, 2010 at 7:58 PM

How can I call a function I wrote in IronScheme from C#? In Clojure, I can write something like:


(ns com.ociweb.clj.Demo
   :methods [#^{:static true} [getMessage [String] String]]))

# Note the hyphen at the beginning of the function name!
(defn -getMessage [name]
  (str "Hello, " name "!"))


and then call it from Java like this:


import com.ociweb.clj.Demo; // class created by compiling Clojure source file

public class Main {

    public static void main(String[] args) {
        String message = Demo.getMessage("Mark");


Is there a way to do the same thing with IronScheme and C# ? Are there plans to create something like Clojure gen-class?

Feb 27, 2010 at 8:22 PM

Maybe by calling Reflection.Emit with IronScheme? are there some examples of that somewhere?

Feb 27, 2010 at 8:35 PM

I found this code example after searching in Google: IronScheme Reflection Emit.

Is this an example of how to define a class (inside an assembly) in Iron Scheme?:


(define myhello
    (assembly myhello)
    (module myhello.dll
      (type foo public
        (method bar (public static) (System.Int32 => System.Int32)
        (method baz (public static) (=> System.Int32)
          (ldc.i4 1)



Looks very low level... Anyone on this forum knows a of higher level example or guide on how to do this?

Feb 27, 2010 at 8:53 PM


The code in your above post was an experiment. I kinda hit a wall on it, and need to think about it a lot more  :(

As IronScheme currently uses an incremental compiler approach, all code is compiled to memory, with the exception of the bootfile.

I hope to someday make it fully compiled (I have experimented with some ideas).

For now the best way to call Scheme from C# is to the approaches shown in the documentation.

If you are using .NET 4, you can try using (and improving) the 'dynamic' proof of concept I did.

I also hope to improve on this once .NET 4 goes RTM.