3 ms·
micro ML/lisp to C isn't too involved, really! 1. Convert to continuation-passing style (or ANF) 2. Perform closure conversion 3. Hoisting nested functions/l
by shpongled 5y ago
micro ML/lisp to C isn't too involved, really!
1. Convert to continuation-passing style (or ANF)
2. Perform closure conversion
3. Hoisting nested functions/lambda lifting
4. Generate C! (and then write a runtime/GC).
Targeting lua should be much easier
- throw10920 5y agoWhere can one read about these steps in an easily-digestible format?
- shpongled 5y agoUnfortunately, I haven't found a ton of "easily-digestible" and, at the same time, comprehensive guides on compiling functional languages. Generally you'll find a mix of blog posts/class notes/papers covering a single step. Some resources I like: - Andrew Kennedy's 2007 paper Compiling with Continuations, Continued [1]. This one is the most clear IMO - Andrew Appel's Compiling with Continuations book (a bit outdated though... assembly code is for VAX) - Matt Might's series [2] - MLton's source and documentation [3] [1] https://www.microsoft.com/en-us/research/wp-content/uploads/2007/10/compilingwithcontinuationscontinued.pdf https://www.microsoft.com/en-us/research/wp-content/uploads/... [2] https://matt.might.net/articles/closure-conversion/ https://matt.might.net/articles/closure-conversion/ [3] http://mlton.org/ http://mlton.org/