Implementating functional languages for the CLR (Or, papers on the implementation of F#)

依然范特西╮ 提交于 2019-12-07 13:00:00

问题


Does anyone know of any good papers on the implementation of the F# compiler? I'm trying to generate CIL code for a simple functional language targeting the CLR, but I am struggling with a few aspects.

The differences between functional languages and CIL are making it hard to generate well-typed CIL code. I have solutions that work via type erasure, but I'd much rather find a way to generate CIL code that reflects (to at least some extend) the Hindley-Milner type system of my source language (e.g., by generating generic classes). Judging by the generated code from the MS and Mono F# compilers, they manage to achieve exactly this!


回答1:


There aren't many academic papers on the implementation on F# - although the compiler is open-source, so you can explore the source code if you want to learn about some specific details. (BTW: the F# compiler available in Mono is based on the open-source release, so it is essentially the same as the F# compiler available in Visual Studio).

The only relevant academic publication is Don Syme's paper ILX: Extending the .NET Common IL for Functional Language Interoperability. It is quite interesting reading - it discusses how the IL could be extended to make compilation of functional languages easier. Under the cover, the initial versions of F# compiler compiled to this extended IL (ILX), which is then translated to ordinary IL. The details have probably changed since then, but the core principles will be the same.



来源:https://stackoverflow.com/questions/8002529/implementating-functional-languages-for-the-clr-or-papers-on-the-implementatio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!