Curious about IronScheme's implementation

Aug 5, 2014 at 10:16 AM
Warning: Silly questions abound. I haven't looked into the source code at all, so these questions are most likely horribly mis-informed.

Does IronScheme compile down to CIL like C# and F#? From memory, I thought that it used a modified version of the DLR? Would it be possible to implement a Scheme that compiles to CIL and if so, are there any advantages to doing this?

Would it be useful to be able to produce assemblies that other languages can consume or maybe produce proper sub-classes of existing .NET types? Can you actually implement some of the more advanced Scheme features, like evaluations, on the CLR?
Coordinator
Aug 5, 2014 at 3:11 PM
Edited Aug 5, 2014 at 3:13 PM
Does IronScheme compile down to CIL like C# and F#? From memory, I thought that it used a modified version of the DLR? Would it be possible to implement a Scheme that compiles to CIL and if so, are there any advantages to doing this?
Yes, it does use a heavily modified version of the DLR. The DLR does compile down to CIL bytecode. In hindsight, it would have been better if I choose the CCI or F# as the underlying platform instead. Too late now, and have no inspiration to do it all again :)
Would it be useful to be able to produce assemblies that other languages can consume or maybe produce proper sub-classes of existing .NET types? Can you actually implement some of the more advanced Scheme features, like evaluations, on the CLR?
It can already produce assemblies for libraries, but there are not really usable directly from other .NET languages mostly due to the fact that C# cannot refer to some names used commonly used in Scheme. You can inherit from a .NET type, but that is about it :( You cannot override methods, unless you add some 'glue' to the base class.

I dont understand what you mean by evaluations. IronScheme has an incremental compiler and compiles all code. eval is like an interface to the compiler viewed from Scheme.
Aug 6, 2014 at 4:04 AM
Edited Aug 6, 2014 at 7:38 AM
Thanks for your answers! It is interesting to see how IronScheme works. I'll need to have a look at the source code as well! Sorry by evaluations I actually meant continuations :-\ Oops.

How does inheriting from a .NET type look in Scheme? I couldn't see any specific methods in the CLR syntactic interface page? In theory, would it be possible to make an object system library that maps nicely to .NET and can extend and create new classes, in IronScheme? Or is there some hard technical limitation that would prevent it?
Coordinator
Aug 7, 2014 at 12:31 PM
Thanks for your answers! It is interesting to see how IronScheme works. I'll need to have a look at the source code as well! Sorry by evaluations I actually meant continuations :-\ Oops.
There is really only one way to implement this and it is via CPS. Doing that, pretty much kills interoperability with .NET (every 'native' function call will have to be wrapped in a delegate that accepts a continuation).
How does inheriting from a .NET type look in Scheme? I couldn't see any specific methods in the CLR syntactic interface page? In theory, would it be possible to make an object system library that maps nicely to .NET and can extend and create new classes, in IronScheme? Or is there some hard technical limitation that would prevent it?
define-record-type allows you to have a parent class, this could in theory be any .NET type. With records you only have fields, so only those can be added. Scheme procedures are compiled as static methods, generally accepting an instance as the first parameter.