Adventures with IronScheme

TL;DR; I wasted an afternoon attempting something I think is impossible with IronScheme.

Off and on I’ve been playing around with Lisps that target the CLR.  I was newly energized by articles about writing Lisps in F# so I decided to give it a try.  I met a bit of resistance since I haven’t used OCaml since… 2004.  So instead of working that out I figured if I used IronScheme I’d already have a parser, so I could just skip to the generating CLR part of the problem, but alas I think I’ve ran into a impassable wall.

While trying to use the System.Reflection.Emit library I was perturbed that interfacing with C# libraries from IronScheme were so verbose, unlike the nifty Java interop in Clojure.  Example:

Most of that can be hidden with macros, but it still requires you to specify the type of the instance you are calling the method on and thats annoying.  But that wasn’t the impassable wall.  The impassable wall is I couldn’t figure out how to ‘or’ enumerations.  System.Reflection.Emit.ModuleBuilder.DefineDynamicAssembly takes in System.Reflection.TypeAttributes which are an enum that you are exported to ‘or’, like this type is public and a class.  I tried hard to ‘or’ them with IronScheme using the bitwise-ior function sometimes in combination with clr-cast but I couldn’t get it to work.  I finally gave up when I saw that there was a footnote in the IronScheme documentation that out parameters aren’t supported, that was the signal to me that not everything is possible with IronScheme C# interop and I gave up.  What a waste of an afternoon, I thought for sure it was going to be productive.

Then problem case:


Leave a Reply

Your email address will not be published. Required fields are marked *