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

Posted by: leppie | June 2, 2009

IronScheme debugging

Hi

To show the new debugging features of IronScheme, I have made a little screencast of it in action :)

IronScheme Debugging

To enable debugging of scripts, simply execute (debug-mode? #t) and attach a debugger to IronScheme.Console, and set a breakpoint in the scripts source file.

Posted by: leppie | May 8, 2009

IronScheme now passes all the SRFI tests

Yay! :)

So they are good for use, and will be included in the next release.

Posted by: leppie | May 2, 2009

Small update to IronScheme 1.0 beta 3

Over the last week I have found a few annoying bugs related to printing of exception, especially during read time.

I have now updated the release to beta 3a.

Also included is a bug fix for parameter handling.

Download from here.

Thanks :)

leppie

Posted by: leppie | April 27, 2009

IronScheme 1.0 beta 3 released

The new beta is out now.

I have tried to recreate the 64-bit issue with no luck, but I have a hunch it could be a version issue. Let’s see where the release takes us :)

If the bug persist, please log a bug at the project page for IronScheme.

Download from here.

UPDATE:

I have managed to get someone to test for me on Windows 64-bit, and the results for both IronScheme and xacc.ide were successful.

Posted by: leppie | April 3, 2009

IronScheme update

Hi

Recently I have been converting a lot of procedures from their C# implementation to Scheme. This has proved to be rather successful as the compiler has matured to such a point that it is within 50% of writing the code in C#. While doing this, I have identified several optimizations that can be applied :) This will most notably be applied in version 2 when the compiler rewrite will happen.

For now, IronScheme only have 20 procedures left not implemented in Scheme in the (rnrs base) library with most other completely converted with the noted exception of hashtables, records, ports and exceptions. This is all while keeping the performance and GC ’snappiness’ up to par.

As IronScheme 1.0 Beta 2 has been very successful in the last few months I have decided to make the release interval for every 500 downloads of the previous version. So, the quicker you download, the quicker a new release will appear, until I am satisfied with the requirements for a full on version 1.0 (I am kinda eager to get on with the next version!).

Cheers

leppie

Posted by: leppie | March 5, 2009

System.Double deconstruction extension methods

Recently I discovered an issue with the = procedure in IronScheme, anyways, I was interpreting the semantics incorrectly, and realised I had to deconstruct my floating point representation (System.Double) to get the exact representation of the number, then present it as a rational to check for mathematically correct equality.

NOTE: this code needs some form of big number (the one used here is from the DLR) that can do bitshifting or big powers (up to 1023) of 2.

static class DoubleExtensions
{
  const long MANTISSA_MASK = (long)(ulong.MaxValue >> (64 - 52));
  const long EXPONENT_MASK = (long)(ulong.MaxValue >> (64 - 11));
  const long SIGN_MASK = 0x1;

  public static long GetMantissa(this double d)
  {
    var r = BitConverter.DoubleToInt64Bits(d);
    return GetMantissa(r);
  }

  static long GetMantissa(long r)
  {
    return r & MANTISSA_MASK;
  }

  public static int GetExponent(this double d)
  {
    var r = BitConverter.DoubleToInt64Bits(d);
    return GetExponent(r);
  }

  static int GetExponent(long r)
  {
    r >>= 52;
    return (int)(r & EXPONENT_MASK);
  }

  public static int GetSign(this double d)
  {
    var r = BitConverter.DoubleToInt64Bits(d);
    return GetSign(r);
  }

  static int GetSign(long r)
  {
    r >>= 63;
    return (int)(r & SIGN_MASK);
  }

  readonly static BigInteger MANTISSA = (ulong.MaxValue >> (64 - 52)) + 1;

  public static bool GetComponents(this double d, out BigInteger numerator, out BigInteger denominator)
  {
    if (double.IsNaN(d))
    {
      numerator = denominator = 0;
      return false;
    }

    if (double.IsNegativeInfinity(d))
    {
      numerator = -1;
      denominator = 0;
      return false;
    }

    if (double.IsPositiveInfinity(d))
    {
      numerator = 1;
      denominator = 0;
      return false;
    }

    if (d == 0.0)
    {
      numerator = 0;
      denominator = 1;
      return true;
    }

    var r = BitConverter.DoubleToInt64Bits(d);

    var m = GetMantissa(r);
    var e = GetExponent(r);
    var s = GetSign(r) == 0 ? 1 : -1;

    const int BIAS = 1023;
    var re = e - BIAS;

    var exp = (((BigInteger)1) << Math.Abs(re));

    if (re < 0)
    {
      denominator = MANTISSA * s * exp;
      numerator = (MANTISSA + m);
    }
    else
    {
      denominator = MANTISSA * s;
      numerator = exp * (MANTISSA + m);
    }

    return true;
  }
}
Posted by: leppie | March 5, 2009

Tree traversal extension methods

public static class TreeExtensions
{
  public static IEnumerable<R> TraverseDepthFirst<T, R>(
    this T t,
    Func<T, R> valueselect,
    Func<T, IEnumerable<T>> childselect)
  {
    return t.TraverseDepthFirstWithParent(valueselect, childselect).Select(x => x.Key);
  }

  public static IEnumerable<KeyValuePair<R, T>> TraverseDepthFirstWithParent<T, R>(
    this T t,
    Func<T, R> valueselect,
    Func<T, IEnumerable<T>> childselect)
  {
    return t.TraverseDepthFirstWithParent(default(T), valueselect, childselect);
  }

  static IEnumerable<KeyValuePair<R, T>> TraverseDepthFirstWithParent<T, R>(
    this T t,
    T parent,
    Func<T, R> valueselect,
    Func<T, IEnumerable<T>> childselect)
  {
    yield return new KeyValuePair<R, T>(valueselect(t), parent);

    foreach (var i in childselect(t))
    {
      foreach (var item in i.TraverseDepthFirstWithParent(t, valueselect, childselect))
      {
        yield return item;
      }
    }
  }

  public static IEnumerable<R> TraverseBreadthFirst<T, R>(
    this T t,
    Func<T, R> valueselect,
    Func<T, IEnumerable<T>> childselect)
  {
    return t.TraverseBreadthFirstWithParent(valueselect, childselect).Select(x => x.Key);
  }

  public static IEnumerable<KeyValuePair<R, T>> TraverseBreadthFirstWithParent<T, R>(
    this T t,
    Func<T, R> valueselect,
    Func<T, IEnumerable<T>> childselect)
  {
    yield return new KeyValuePair<R, T>(valueselect(t), default(T));

    List<T> children = new List<T>();

    foreach (var e in childselect(t))
    {
      children.Add(e);
      yield return new KeyValuePair<R, T>(valueselect(e), t);
    }

    while (children.Count > 0)
    {
      foreach (var e in new List<T>(children))
      {
        children.Remove(e);
        foreach (var c in childselect(e))
        {
          children.Add(c);
          yield return new KeyValuePair<R, T>(valueselect(c), e);
        }
      }
    }
  }
}

// usage
interface INode<T>
{
  T Value { get; }
  IEnumerable<INode> Children { get; }
}

INode<int> root = ...

foreach (var i in root.TraverseDepthFirst(x => x.Value, x => x.Children))
{
  Console.WriteLine(i);
}
Posted by: leppie | February 17, 2009

DataContext.RevertChanges()

Here is a nice extension method I dished up, to revert all changes in the DataContext. :)

(drop this in your DataContext partial class, or create a static/extension method for it)

public void RevertChanges()
{
  var cs = GetChangeSet();

  foreach (var item in cs.Inserts)
  {
    var t = item.GetType();
    GetTable(t).DeleteOnSubmit(item);
  }

  foreach (var item in cs.Deletes)
  {
    var t = item.GetType();
    GetTable(t).InsertOnSubmit(item);
  }

  foreach (var item in cs.Updates)
  {
    var t = item.GetType();
    foreach (var mm in GetTable(t).GetModifiedMembers(item))
    {
      var pi = mm.Member as PropertyInfo;
      if (pi != null)
      {
        pi.SetValue(item, mm.OriginalValue, null);
      }

      var fi = mm.Member as FieldInfo;
      if (fi != null)
      {
        fi.SetValue(item, mm.OriginalValue);
      }
    }
  }
#if DEBUG
  cs = GetChangeSet();
  Debug.Assert(cs.Deletes.Count == 0);
  Debug.Assert(cs.Inserts.Count == 0);
  Debug.Assert(cs.Updates.Count == 0);
#endif
}

« Newer Posts - Older Posts »

Categories