News for hackers. Stuff that matters.
Re:Chumsky: A Tutorial by giraffe_lady on Tuesday April 12, 2022 @02:59PM (#31006917)
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.

Re:Chumsky: A Tutorial by shpongled on Tuesday April 12, 2022 @05:54PM (#31008688)
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

Re:Chumsky: A Tutorial by throw10920 on Tuesday April 12, 2022 @05:58PM (#31008737)
Where can one read about these steps in an easily-digestible format?
Re:Chumsky: A Tutorial by shpongled on Tuesday April 12, 2022 @06:27PM (#31008999)
Unfortunately, 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/...

[2] https://matt.might.net/articles/closure-conversion/

[3] http://mlton.org/

Re:Chumsky: A Tutorial by xigoi on Tuesday April 12, 2022 @04:52PM (#31008093)
Re:Chumsky: A Tutorial by giraffe_lady on Tuesday April 12, 2022 @05:58PM (#31008734)
I 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.

Re:Chumsky: A Tutorial by sitkack on Tuesday April 12, 2022 @05:16PM (#31008326)
A pretty-printer for your tiny ML could emit Lua. I mean you even get proper tail calls! It would be a real ML.