How to compile with continuations
matt.might.net
matt.might.net
"I don't have time to learn about PL theory! I'm too busy reinventing how to implement basic control flow and concurrency in a bad-ass rock-star programming environment!"
Maybe when Prometheus brings generator expressions down to us mere mortal node.js programmers, then we can express how to do two things in sequence!
It sounds trivial, but in practice it dramatically reduces the size of not only optimization passes such as inlining, but it makes analyses that drive optimizations simpler as well (e.g., control-flow analysis). For an example from my experience (Manticore - http://manticore.cs.uchicago.edu/), my pretty coarse CFA analysis on our direct-style IR is about 750 lines of SML code whereas an optimized CFA with three different variants and extra support for environment analysis is only 700 lines of SML.
[1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.3...
If you allow first-class continuations in user programs, though, all bets are off and CPS is more expressive.
Richard Kelsey wrote the paper that talks about how to convert between CPS and SSA forms, along with the first-class continuation limitation mentioned above:
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.3.67...
Goto via exceptions? An intriguing idea, but I guess exceptions are glorified goto in any case. The generated source must be interesting, though.
However, this is a complex article. I feel like I was only able to grasp the substance because I already know a bit about continuation — though this automated and hybrid approach is quite new to me.
I wonder how hard this text is to understand, for someone who does not know what "continuations" are.
recently I asked if people wanted to have a look at and comment on the abstract math pieces I'm slowly writing[0] and a number have said yes. Someone replied[1] that they "would love a simply math blog." The problem is, the simple stuff you'll skim, the complex stuff you'll get frustrated by, and no one will be happy.
Unless you go through the stages you won't have the skills for the next level, and until you get exposed to the higher levels, you won't realize that there's more work to do. This is, of course, related to the "Blub paradox"[2] that we're all so familiar with.
[0] https://news.ycombinator.com/item?id=7139635
I am simply wondering how the average HN reader, with average programming abilities and knowledge, would feel about an article of this level.
Some of them will have been autodidacts who have taught themselves this sort of thing already. Some will be autodidacts who have enough foundations to be ready to understand this.
But some will not. Some will have picked things up here and there and become useful programmers, but find this sort of thing hard going and mind-blowing. The question was to wonder what proportion of HN readers fall in each category.
As for CS graduates, I suspect that even those who had a course in that area might not actually be that interested - I was fascinated by lambda calculus, combinators and implementations of functional languages so the article was probably more interesting for me than most.
Quines is as simple as saying that you want eval(x)==x, and it will try to fill in answers for x. It's a bit underwhelming, though, to realize that it will tell you that "5" is a quine, since eval(5)==5.
You don't think that would be enough to explain continuations to a working programmer? It doesn't really use any specific or formal mathematical language, and explains them mostly in terms of js with examples.
[1] - http://common-lisp.net/projects/cl-cont/
[2] - https://github.com/skypher/clbuild.mystic/tree/master/source...