Posted by: leppie | November 16, 2009

Experimental monolitic IronScheme executable


A common request is to have some form of compiled libraries to run a Scheme program, and not relying on source files for the program to run.

This is already provided in IronScheme via precompiled/serialized libraries, but still results in a ‘binary’ format for every library file, which in turn can end up being quite a few with a fixed directory structure.

So yesterday I worked around a serialization bug that hindered my progress on improving this.

I have added the following:
1. Created a container package to shove all precompiled libraries in.
2. Added the ability to use ILMerge to merge all the assemblies into 1 executable.
3. And for bonus points, I added the ability to include the container package into such a merged executable, resulting in 1 fat executable with all the libraries included.

For now, you can go to this IronScheme page and download the result of step 3. A 21MB executable with everything to run IronScheme, including all IronScheme and SRFI and miscellaneous libraries.

Of course your own program may not need all the libraries, so you could chose to only merge the ‘base’ 2.1mb executable with say 1mb of libraries.

I will add some documentation later to explain how to craft these.



Posted by: leppie | October 27, 2009

IronScheme and C# 4’s new dynamic keyword

So everyone (well all the IronXXX people) is doing it, so I might well too 🙂

I present using IronScheme in C# 4:

class Program
  static dynamic Scheme = new SchemeEnvironment();

  static void Main(string[] args)
    var list = Scheme.list;
    var map =;
    var reverse = Scheme.reverse;

    Func<int, int> f = x => x * x;

    var r = map(f, reverse(map(f, list(1, 2, 3))));

    Console.WriteLine(; // prints 81

The implementation is straight forward, and can be viewed here. I just involves a simple Linq expression. 🙂



Posted by: leppie | October 24, 2009

IronScheme 1.0 RC 1 released


After just over 1 year in beta phase, IronScheme has moved into release candidate phase.

Download and release notes for IronScheme 1.0 RC 1.



Posted by: leppie | October 13, 2009

Replaced BigInteger implementation with a faster one


I have recently checked in code that completely removes the usage (and in fact removes it from existence) of the DLR’s BigInteger implementation and replaces it with the IntX big number implementation.

The new code provides much better performance in terms of multiplication of very big numbers. Although I have not benchmarked it, I suspect the other operations are slightly faster too, given that quality of the implementation.

The ‘port’ was done in-place. First, the C# was modified and recompiled, then the bootfile was disassembled, and patched with the new type, and recompiled. Lastly, the new type was extended to make its interface (aka public methods) was compatible in terms of IL method signatures.

The rest, just involved some testing, and minor bug fixing. It should all work as before, and be completely transparent.

I did however come across a weirdass bug, where a case statement will fail to match. I couldn’t repro it at all, even after days of debugging/trying/crying….

Please notify me of any big number related bugs 🙂



Posted by: leppie | September 22, 2009

IronScheme now supports compile time records

As per the R6RS, I have now partially exploited compile time information to define record types at compile time if possible. Currently, it is only possible in the bootfile and only defines the ‘shape’ of the record (iow fields).

Further work will include making direct constructor (if possible), predicate, accessor and mutator references. This should provide a nice little speed boost.



Posted by: leppie | August 21, 2009

(ironscheme clr shorthand)

I have moved with-clr-type and friends to the (ironscheme clr shorthand) library.

clr-call, clr-field-get and clr-field-set! have been modified to infer the type based on the instance argument. This is good news, as it allows me to apply with-clr-type‘s shorthand syntax fluidly (or recursively).

To utilize this feature, you simply have to pass #f as the type argument in the macros. Note: This only applies to instance members. For static members, you are still required to provide the type.

The method and indexer syntax has been slightly modified to accommodate this.

The new body syntax is as follows (rest denotes continuable syntax):

(obj : id (arg ...) . rest) ; calls method 'id' with args
(obj : (arg ...) = value)   ; sets the indexer with args to a value
(obj : (arg ...) . rest)    ; gets the indexer with args
(obj : id = value)          ; sets a property 'id' to a value
(obj : id . rest)           ; gets a property 'id'
(obj -> id = value)         ; sets a field 'id' to a value
(obj -> id . rest)          ; gets a field 'id'

Example (given the class defined in the previous posting):

(let-clr-type ((obj (TestClass "foo"))) 
  (obj : Message : (1))) ; C#: obj.Message[1]
=> #\o

Also added to the (ironscheme clr shorthand) library are define-clr-type and lambda-clr-type syntax, that binds and defines procedures with their arguments tagged as CLR types.

As you can see, now the ability to use .NET libraries should be a lot easier. 🙂

Posted by: leppie | August 19, 2009

Added another CLR helper – let-clr-type

This one looks like a normal ‘let’ form, but binds to CLR constructed objects instead.


(let-clr-type ((obj (TestClass "foo))) ; same as 'clr-new', but without 'clr-new' identifier
   (obj : Message))
Posted by: leppie | August 16, 2009

New CLR shorthand syntax

I have added a new macro called ‘with-clr-type’, that tags an identifier with a CLR type, and this allows to write shorter syntax.

Given the following class:

  public class TestClass
    public string Source;
    public string Message { get; set; }

    public TestClass()


    public TestClass(string msg)
      Message = msg;

    public void Print(string hello)
      Console.WriteLine("{0} {1}", hello, Message);

    public char this[int i]
      get { return Message[i]; }
      set { Message = i.ToString() + value.ToString(); }

One can do the following:

> (import (ironscheme clr))
> (clr-using IronScheme)
> (let ((obj (clr-new TestClass "foo")))
.   (with-clr-type ((obj TestClass)) ; can tag multiple ids
.     (printf "~a\n" (eq? obj 50)) ; normal reference, do nothing
.     (printf "~a\n" (obj : Message)) ; property get
.     (obj : Message = "world") ; property set
.     (printf "~a\n" (obj -> Source)) ; field get
.     (obj -> Source = "bar") ; field set
.     (printf "~a\n" (obj -> Source)) ; field get
.     (obj Print "hello") ; method call
.     (printf "~a\n" (obj (1))) ; indexer get
.     (obj (99) = #\a) ; indexer set
.     (obj : Message) ; property get
.     ))
hello world

Which is a lot shorter than the normal way. 🙂

The Scheme Programming Language – Fourth Edition

The new edition focuses on R6RS, which is the latest version of the Scheme language, and the one that IronScheme supports.

Great reading! 🙂

Thanks to Reddit (and the authors).


The site seems to have been taken down for unknown reasons. Let’s hope it reappears soon!

Update 2:

The site is now back up 🙂

Posted by: leppie | July 23, 2009

IronScheme 1.0 beta 4 released

IronScheme 1.0 beta 4 is now available here.

Please see the release notes for changes/fixes.

This will also be the last beta before a possible release candidate, and the final 1.0 version.



« Newer Posts - Older Posts »