2015-06-05 6:37 GMT+02:00 Neil Van Dyke <n...@neilvandyke.org>:
> 2. Forget about `eval`, require apps to be compilable on development host > (but not necessarily runnable there), implement compiler from `.zo` to JS > (managing TCO, etc.), implement small Racket runtime library in JS, > implement browser facilities and/or GUI libraries in JS. Later think about > `eval`.[*] > This approach seems to be what Whalesong does. I agree that `eval` is unimportant for most programs - and when a Racket version of the new macro expander is available it ought to be reasonably easy to implement `eval`. > > [*] I've only done a very brief peek at sample `zo-parse` and `decompile` > output, so I don't know how tricky it can get, but the little I saw looked > like a static translation to JS wouldn't be too difficult. I don't know > how necessary `eval` is if you have bytecode, nor how much of the > primitives would have to be implemented manually rather than translated > from `.zo`. There are a few complications. It is hard to use the native JavaScript stack to represent the Racket stack. Some byte codes like with-cont-mark manipulate the stack in ways JavaScript doesn't support. Some primitives (call/cc and friends) are also problems unless an explicit representation of the Racket stack is used. Whalesong compiles zo-bytecode into JavaScript that manipulate an explicit data structure representing the Racket stack. The alternative approach is to compile fully expanded Racket into JavaScript. The trio of TCO, contination marks and continuations will most likely turn out to be the trickiest to get right. Even with an explicit control stack for Racket care is needed to avoid hitting the stack ceiling in JavaScript (why was `goto` left out in the cold?) Finally - a small runtime library is probably unrealistic. Racket has a huge number of primitives. Relevant paper on continuation marks and continuations from exceptions: http://cs.brown.edu/~sk/Publications/Papers/Published/pcmkf-cont-from-gen-stack-insp/paper.pdf Note: The paper "Implementing Continuation Marks in JavaScript" shows how to add continuation marks to an existing JavaScript engine (Rhino), but unfortunately that won't help in a general context. Implementing Continuation Marks in JavaScript John Clemens, Ayswarya Sundaram, and, David Herman http://www.ccs.neu.edu/home/dherman/research/papers/scheme08-stack-marks.pdf -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.