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 = Scheme.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(r.car); // prints 81
  }
}

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

Cheers

leppie

Posted by: leppie | October 24, 2009

IronScheme 1.0 RC 1 released

Hi

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.

Cheers

leppie

Posted by: leppie | October 13, 2009

Replaced BigInteger implementation with a faster one

Hi

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 :)

Cheers

leppie

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.

Cheers

leppie

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.

Usage:

(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
.     ))
#f
foo
()
bar
hello world
o
"99a"
>

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).

Update:

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.

Cheers

leppie

Posted by: leppie | July 5, 2009

IronScheme documentation update

Over the last week or so, I have after some inspiration (and help from Fufie), added a bunch of documentation to the codeplex site.

You can have a look here.

As an added bonus, I wrote a little commandline webserver, that show cases another extension to the documentation (think library browser).

The webserver is included in the latest checkin, and is only tested on Vista, running from the installation directory. It will be included in the next release.

UPDATE

The webserver runs in XP too. You just need to prepare the bin directory of the webroot.

Simply copy the following files and directories to the webroot’s bin directory:

  • IronScheme.dll
  • IronScheme.Web.Runtime.dll
  • IronScheme.Closures.dll
  • Microsoft.Scripting.dll
  • ironscheme.boot.dll
  • ironscheme dir
  • lib dir (optional)
  • srfi dir (optional)

Cheers

leppie

Older Posts »

Categories