Mon Jan 21 11:08:51 CET 2013

Can #%app be overridden locally?

What I'm looking for is probably a `lambda' macro that iterates over
syntax and inserts `my-app' in the proper places.

Yes, it does work.  After reading the doc it says that `#%app' is
inserted by the macro expander with the lexical context of the
expression, so I tried the following:

  (let-syntax ((#%app (syntax-rules () ((_ . a) 'a)))) (foo 1 2 3))
  =>(foo 1 2 3)

The trouble is that redefining #%app in a lambda form needs insertion
of non-hygienic #%app == same context as inserted by the expander.
After a bit of experimenting, it seems that this is a bad idea.  It
seems better to implement a new lambda form that performs its own
recursion over an expression throuh inserting its own `app' and
`datum' references.  The "global variable" #%app thing doesn't seem to
be such a good idea, except when implementing a language that never
inserts or is inserted into another language context.  In sort, in
Staapl there are "local language contexts" in the form of macros that
perform special-case interpretation.

[1] http://docs.racket-lang.org/reference/application.html?q=%23%25app