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

From: Marco Monteiro (masm at acm.org)
Date: Fri Nov 20 17:09:40 EST 2009

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

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

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.



P.S. Yes, I am aware of Moby.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091120/d06cb835/attachment.html>

Posted on the users mailing list.