[racket-dev] `cond' / `when' / `unless' / etc bodies

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Oct 12 10:56:46 EDT 2010

At Tue, 12 Oct 2010 10:43:03 -0400, Eli Barzilay wrote:
> An hour ago, Matthew Flatt wrote:
> > At Mon, 11 Oct 2010 20:38:58 -0400, Eli Barzilay wrote:
> > > > At Mon, 11 Oct 2010 19:15:09 -0400, Eli Barzilay wrote:
> > > > > I'd love to see an implicit `#%begin', which could have the
> > > > > above apply in more places automatically.  (It was one of the
> > > > > feature requests I asked for in the summer meeting.)
> > > > 
> > > > Recall that no one solved the technical problem with where to
> > > > pull the lexical context for the implicit `#%begin' or `#%body':
> > > > 
> > > >   http://lists.racket-lang.org/dev/archive/2010-July/003624.html
> > > 
> > > I remember being confused with how that problem would look like,
> > > but I don't think that I've seen an example where this would be
> > > problematic.  (I think that we talked about it, but I can't
> > > remember any concrete details...)
> > 
> > Can you say more about how the `squawk' example in the referenced
> > post doesn't illustrate the problem?
> 
> It doesn't specify any clear problem -- either that or I'm missing
> something obvious...  AFAICT, the problem that is described there is
> similar to:
> 
>  (define-syntax-rule (squawk body ...)
>    (begin
>      (printf "squick ~a!" "squawk")
>      (let () body ...)))
> 
> having the implicit `#%app' come from this macro's module rather than
> the use site, for example, if it's defined in a module that has
> implicitlty curried applications then the `printf' call becomes
> curried.

Isn't the point of a configurable "implicit begin" that `squawk' can
inherit the implicit-begin behavior of the use site instead of the
definition site? That is, the intent of the example is that the
`squawk' syntactic form has a body, and "body" means whatever it's
configured to mean at the use site.

Other macros, meanwhile, may expand to uses of `let' where the body of
the `let' is meant to be used as in the context of the definition site
(probably because the body of that `let' is not supplied as an argument
to the macro).

So, how does a macro implementor make the distinction between those
kinds of `let's?



Posted on the dev mailing list.