3 ms·
haha timely comment for me. I'm currently working on a project where I have no choice but to target a limited form of lua 5.1, but have total freedom within tha
by giraffe_lady 5y ago
haha timely comment for me. I'm currently working on a project where I have no choice but to target a limited form of lua 5.1, but have total freedom within that constraint.
Was considering what it would take to write a small ML that compiles to lua. "Almost certainly more than I'm willing to put in" was my tentative unresearched conclusion but this validates it a bit.
- sitkack 5y agoA pretty-printer for your tiny ML could emit Lua. I mean you even get proper tail calls! It would be a real ML.
- xigoi 5y agoTake your pick: https://github.com/hengestone/lua-languages https://github.com/hengestone/lua-languages
- giraffe_lady 5y agoI spent a few hours with this list a few weeks ago and nah. They're all abandoned, or undocumented, or incomplete, or target luajit, or intensely nonstandard, or surface the underlying lua behavior I'm trying to avoid. Usually a mix of some of those. The lisp ones look solid and I love lisp, but for this specific thing a good type system would be most valuable.
- shpongled 5y agomicro 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/