<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Nov 20, 2009, at 5:09 PM, Marco Monteiro wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">So, I am writing a Scheme to JavaScript compiler. Because I want to<br>write the macro and module system later, my idea was to use<br>PLT Scheme's macro and module system, for now. Of course, this<br>probably must be done with some kind of hack. I'm just trying to find<br> one that is reliable.<br><br>My first approach was to expand the module in the reader, store this <br>expanded code (later will be translated to JavaScript), and replace<br>the expressions in the expanded code by (void), so that the module<br> just read, and to be returned by the reader, has no expressions. This<br>is necessary because this code is to be evaluated later in the web<br>browser. I'm using PLT to read, macro-expand but not evaluate the<br>module.<br> <br>After reading what you wrote, I changed the process a bit. I still expand<br>the code in the reader but then I return the read module, without <br>replacing the expressions, but in a different language. In that new language,<br> I have #%app to expand to #'(void). It works, but I have two languages<br>that are different only in the provided #%app.<br><br>Now I'm trying a new approach. Instead of expanding the module in the<br>reader, I export a #%module-begin that replaces its subforms by a <br> new macro that code-walks by using local-expand and some other <br>hacks. This does not mix read and macro expansion levels, but I have to<br>10 times more code.<br></blockquote><div><br></div><div>This sounds like the best way to do what you want. </div><div><br></div><div>You might also find it useful to read "Advanced Macrology and the Implementation of Typed Scheme" as a source of ideas and techniques for working with PLT's macro system:</div><div><br></div><div> <a href="http://www.ccs.neu.edu/scheme/pubs/scheme2007-ctf.pdf">http://www.ccs.neu.edu/scheme/pubs/scheme2007-ctf.pdf</a></div><div><br></div><div>For example, you can write a #%module-begin macro that local-expands the entire module contents at once, then does a code walk (still at compile time) over the results. You might find that easier to get started with than the compositional approach that you seem to be using (IIUC).</div><div><br></div><div>Ryan</div><div><br></div><div><br></div><div><br></div><blockquote type="cite">Anyway, I know that all this is an hack, but... what is the best way to<br> do what I want? Is there a less hacky way to proceed? <br><br> On Fri, Nov 20, 2009 at 5:15 AM, Eli Barzilay <span dir="ltr"><<a href="mailto:eli@barzilay.org">eli@barzilay.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> But my first thought when I saw that (or rather when someone pointed<br> at your question when you raised it on #scheme) is that you're trying<br> to do some CL-ish kind of a code walker. (And I did see that you<br> mentioned that this is a translation of CL code, so it seems<br> relevant.) In this case, I think that trying to *match* on `#%app's<br> is missing its point. The role of `#%app' is as a kind of a hook that<br> you can use to redefine what happens on every point where a function<br> is being applied *instead* of using a code walker.<br></blockquote></div><br>This code is not ported from CL. Although I do have some work in CL that<br>I want to port to Scheme, this is just my experiments in a new system.<br> I still don't known PLT (and Scheme) well enough to not make some newbie<br>mistakes. That said, I've been writing CL for the last 3 years; probably I'm<br>still thinking in CL.<br><br>Thanks.<br><br>Marco<br> <br> P.S. Yes, I am aware of Moby.<br> <br> _________________________________________________<br> For list-related administrative tasks:<br> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br></blockquote></div><br></body></html>