[plt-scheme] #%app literal does not match in syntax-case pattern

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Fri Nov 20 18:08:32 EST 2009

On Nov 20, 2009, at 5:09 PM, Marco Monteiro wrote:

> So, I am writing a Scheme to JavaScript compiler. Because I want to
> write the macro and module system later, my idea was to use
> PLT Scheme's macro and module system, for now. Of course, this
> probably must be done with some kind of hack. I'm just trying to find
> one that is reliable.
>
> My first approach was to expand the module in the reader,  store this
> expanded code (later will be translated to JavaScript), and replace
> the expressions in the expanded code by (void), so that the module
> just read, and to be returned by the reader, has no expressions. This
> is necessary because this code is to be evaluated later in the web
> browser. I'm using PLT to read, macro-expand but not evaluate the
> module.
>
> After reading what you wrote, I changed the process a bit. I still  
> expand
> the code in the reader but then I return the read module, without
> replacing the expressions, but in a different language. In that new  
> language,
> I have #%app to expand to #'(void). It works, but I have two languages
> that are different only in the provided #%app.
>
> Now I'm trying a new approach. Instead of expanding the module in the
> reader, I export a #%module-begin that replaces its subforms by a
> new macro that code-walks by using local-expand and some other
> hacks. This does not mix read and macro expansion levels, but I have  
> to
> 10 times more code.

This sounds like the best way to do what you want.

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:

   http://www.ccs.neu.edu/scheme/pubs/scheme2007-ctf.pdf

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).

Ryan



> Anyway, I know that all this is an hack, but... what is the best way  
> to
> do what I want? Is there a less hacky way to proceed?
>
> On Fri, Nov 20, 2009 at 5:15 AM, Eli Barzilay <eli at barzilay.org>  
> wrote:
> But my first thought when I saw that (or rather when someone pointed
> at your question when you raised it on #scheme) is that you're trying
> to do some CL-ish kind of a code walker.  (And I did see that you
> mentioned that this is a translation of CL code, so it seems
> relevant.)  In this case, I think that trying to *match* on `#%app's
> is missing its point.  The role of `#%app' is as a kind of a hook that
> you can use to redefine what happens on every point where a function
> is being applied *instead* of using a code walker.
>
> This code is not ported from CL. Although I do have some work in CL  
> that
> I want to port to Scheme, this is just my experiments in a new system.
> I still don't known PLT (and Scheme) well enough to not make some  
> newbie
> mistakes. That said, I've been writing CL for the last 3 years;  
> probably I'm
> still thinking in CL.
>
> Thanks.
>
> Marco
>
> P.S. Yes, I am aware of Moby.
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091120/9a11f361/attachment.html>

Posted on the users mailing list.