John Cowan wrote: > On Dec 29, 2007 9:05 AM, Ola Bini <[EMAIL PROTECTED]> wrote: > > >> I'm looking at implementing a language that would be best represented >> using CPS. Now, I can't really find any references to full CPS >> implementations on the JVM anywhere. I'm looking at using the technique >> Kawa is planning for compiled code (see the last part at >> http://www.gnu.org/software/kawa/internals/complications.html). Has >> anyone else done this? >> > > If you haven't already, I recommend reading Henry Baker's classic > paper "Cheney on the MTA" > <http://home.pipeline.com/~hbaker1/CheneyMTA.html>, which is about > compiling full Scheme to the C "virtual machine", which is close > enough to the JVM as far as control issues are concerned. > Essentially, you compile all functions into CPS, and then each > function calls its successor using an ordinary C function call, never > returning from it. When the C stack gets too full[*], all the data > structures are evicted to the GCed heap, and all the control frames > are discarded by a longjmp back to the beginning. This provides > *amortized* TCO automatically; that is, although stack is pushed, it > gets recycled rapidly -- in essence, the C stack doubles as the first > generation of the Scheme heap. > Hi,
Yes, I've taken a look at that paper, and various other implementations, including Lisp In Small Pieces, which does all these tricks. The problem is that they're all using things that require you to manipulate the stack in some way. setjmp and longjmp can of course be duplicated in a manner by using exceptions, but the rest of the stack manipulation doesn't seem possible. Otherwise, that model would probably work fine. -- Ola Bini (http://ola-bini.blogspot.com) JRuby Core Developer Developer, ThoughtWorks Studios (http://studios.thoughtworks.com) Practical JRuby on Rails (http://apress.com/book/view/9781590598818) "Yields falsehood when quined" yields falsehood when quined. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en -~----------~----~----~----~------~----~------~--~---
