News for hackers. Stuff that matters.
Re:Making a Mini-Lisp: Introduction to Transpilers in JavaSc... by wtbob on Thursday December 24, 2015 @02:22PM (#10789297)
As someone who's been working on figuring out a way to transpile or interpret a powerful dynamic language to Lua, JavaScript, Python and Go, the really tough thing to do is non-local exits. If you can solve that, I think that everything else is easy (well, a Simple Matter of Programming anyway).

It's okay if your target language already supports non-local exits, particularly parameterised ones (although even that can be faked with a well-designed global), but if it doesn't then it's a pain (imagine how you'd do it in Go: every single function call will return an additional value, indicating if a non-local exit is intended).

Alternatively, imagine trying to transpile call/cc to JavaScript…

Re:Making a Mini-Lisp: Introduction to Transpilers in JavaSc... by PeCaN on Thursday December 24, 2015 @02:30PM (#10789323)
Just transform it to continuation-passing style[1] and call/cc is no problem (neither are non-local exits). Granted your compiled code will be somewhat large and not much like 'regular' code in the language. That can be solved by doing selective CPS transform (IcedCoffeeScript[2] does this), but that gets slightly less straightforward.

Compiling continuations to a dynamic language is actually really easy.

--

1: https://en.wikipedia.org/wiki/Continuation-passing_style

2: http://maxtaco.github.io/coffee-script/

Re:Making a Mini-Lisp: Introduction to Transpilers in JavaSc... by wtbob on Thursday December 24, 2015 @05:32PM (#10789776)
> Just transform it to continuation-passing style and call/cc is no problem (neither are non-local exits). Granted your compiled code will be somewhat large

I'm well aware, but CPS code can be _insanely_ large (essentially a function declaration for every line of code in the original source). That's quite painful.

Re:Making a Mini-Lisp: Introduction to Transpilers in JavaSc... by truncate on Thursday December 24, 2015 @05:12PM (#10789729)
I'm interested to know more about IcdeCoffeeScript approach. Any blogs/articles that you know of?

Typically direct CPS conversion are straightforward, but the performance suffers a lot. I'm looking for languages that are using some hybrid approaches.

Re:Making a Mini-Lisp: Introduction to Transpilers in JavaSc... by meric on Thursday December 24, 2015 @06:17PM (#10789889)
Does Javascript's try...catch and error count as non-local exit?